// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // /// jln - 14-08-2008 Column for the sondeer computer. class GUISondeerColumn extends GUIMultiComponent; #exec OBJ LOAD FILE=sondeermeester.utx #exec OBJ LOAD FILE=ExampleFonts_T.utx var GeoLabel TopLabel; var GeoLabel TopValueLabel; var GeoLabel BottomLabel; var GeoImage BackgroundImage; //var automated GeoFrame DialogBackground; var color color_background; var color color_lines; //var float tempoffset; var GeoPlayercontroller GeoPC; /// Number of lines in the gef file. var int GEFLines; /// Minimum depth: var int MinDepth; /// Maximum depth which we will allow before scrolling? var int MaxDepth; /// Current time var int SondeerTime; /// Colours var array Colors[]; //RedColor; var color WhiteColor; var color BlueColor; var color BlackColor; var color BoxColor; /// Label and unit on top headers var string LabelTop, LabelTopUnit; var string LabelBottom, LabelBottomUnit; /// Current value, displayed: var float CurrentValue, BottomValue; /// Which stats to display? var int StatsType1, StatsType2; /// What type to display, graph or just pure text? var int TopType, BottomType; var array ArrayIndex; /// Current depth value: var float CurrentDepth; /// Convert WaterSpanning from mpa to kpa? var bool WaterSpanningToKPA; /// Fonts var Font SmallFont; var Font MediumFont; var Font LargeFont; const GEF_NONE=-1; const GEF_SondeerLengte = 0; const GEF_ConusWeerstand = 1; const GEF_Wrijving = 2; const GEF_Wrijvingsgetal = 3; const GEF_Waterspanning = 4; const GEF_ResultanteHelling = 5; const GEF_HellingNZ = 6; const GEF_HellingOW = 7; const GEF_Diepte = 8; const GEF_Tijd = 9; const GEF_Snelheid = 10; const FORMAT_GRAPH = 0; const FORMAT_TEXTONLY = 1; struct Rect { var float left; var float top; var float right; var float bottom; }; var Rect _verticalline; struct GraphRange { var float rangestart; var float rangeend; var float rangestep; }; var GraphRange rangetop, rangebottom; /// How much the value is altered. var float topdisplacement, bottomdisplacement; /// How many lines to display before we start scrolling. /// Central value used on multiple occasions. var int maxlinesvertical; /// Array of values for the graph. var array topvalues,bottomvalues; /// String SondeerFile, source of the sondeer data: var string SondeerFile; function SetSondeerFile(string file) { SondeerFile = file; GEFLines = int(Localize("Sondering1","linecount",SondeerFile)); MinDepth = 0; MaxDepth = int(Localize("Sondering1","maxdepth",SondeerFile));; } function SetBoxColor(color C) { BoxColor = C; } function SetType(int top, int bottom) { TopType = top; BottomType = bottom; } function SetDisplacementFactor(bool top, float displacement) { if (top) { Log("Set top.."); topdisplacement = displacement; } else { bottomdisplacement = displacement; } } function SetLabelTop(string top, string unit) { LabelTop = top; LabelTopUnit = unit; TopType = FORMAT_GRAPH; BottomType = FORMAT_GRAPH; } function SetLabelBottom(string bottom, string unit) { LabelBottom = bottom; LabelBottomUnit = unit; } function SetStatsType(int Type1, int Type2) { StatsType1 = Type1; StatsType2 = Type2; Log("company: " @ GeoPC.CompanyName); if (GeoPC.CompanyName != "Fugro") { color_background = class'Canvas'.static.MakeColor(128,128,128); color_lines = class'Canvas'.static.MakeColor(160,160,160); } else { /// Special colors for Fugro: color_background = class'Canvas'.static.MakeColor(0,0,0); color_lines = class'Canvas'.static.MakeColor(64,64,64); } switch(StatsType1) { case GEF_ConusWeerstand: rangetop.rangestart = 0; rangetop.rangeend = 25; break; case GEF_Wrijving: rangetop.rangestart = 0; rangetop.rangeend = 0.5; break; case GEF_Wrijvingsgetal: rangetop.rangestart = 0; rangetop.rangeend = 10; break; case GEF_ResultanteHelling: rangetop.rangestart = 0; rangetop.rangeend = 15; break; } switch(StatsType2) { case GEF_Waterspanning: rangebottom.rangestart = -250; rangebottom.rangeend = 1000; break; case GEF_Snelheid: rangebottom.rangestart = 0; rangebottom.rangeend = 10; break; } } /// jln - 01-10-2008 Set current value by hand: function SetCurrentValue(float val) { CurrentValue = val; } function InitComponent(GUIController MyController, GUIComponent MyOwner) { // local int i; Super.Initcomponent(MyController, MyOwner); topdisplacement = 1; bottomdisplacement = 1; // Create the two components // tempoffset = 0.2; topvalues.length = 0; bottomvalues.length = 0; currentvalue = 0; bottomvalue = 0; CurrentDepth = 0; Colors[GEF_SondeerLengte] = class'Canvas'.static.MakeColor(0,0,0, 255); Colors[GEF_ConusWeerstand] = class'Canvas'.static.MakeColor(255,0,0, 255); Colors[GEF_Wrijving] = class'Canvas'.static.MakeColor(0,0,255, 255); Colors[GEF_Wrijvingsgetal] = class'Canvas'.static.MakeColor(255,255,0, 255); Colors[GEF_Waterspanning] = class'Canvas'.static.MakeColor(0,255,225,255); Colors[GEF_ResultanteHelling] = class'Canvas'.static.MakeColor(0,255,0,255); Colors[GEF_HellingNZ] = class'Canvas'.static.MakeColor(255,255,225); Colors[GEF_HellingOW] = class'Canvas'.static.MakeColor(255,255,225); Colors[GEF_Tijd] = class'Canvas'.static.MakeColor(255,255,225); Colors[GEF_Snelheid] = class'Canvas'.static.MakeColor(255,255,225); /*/// jln - 28-10-2008 const GEF_SondeerLengte = 0; const GEF_ConusWeerstand = 1; const GEF_Wrijving = 2; const GEF_Wrijvingsgetal = 3; const GEF_Waterspanning = 4; const GEF_ResultanteHelling = 5; const GEF_HellingNZ = 6; const GEF_HellingOW = 7; const GEF_Diepte = 8; const GEF_Tijd = 9; */ /// Map array type to array index: ArrayIndex[ GEF_SondeerLengte ] = 0; ArrayIndex[ GEF_ConusWeerstand ] = 1; ArrayIndex[ GEF_Wrijving ] = 2; ArrayIndex[ GEF_Wrijvingsgetal ] = 3; ArrayIndex[ GEF_Waterspanning ] = 4; ArrayIndex[ GEF_ResultanteHelling ] = 5; ArrayIndex[ GEF_HellingNZ ] = 6; ArrayIndex[ GEF_HellingOW ] = 7; ArrayIndex[ GEF_Diepte ] = 8; ArrayIndex[ GEF_Tijd ] = 9; ArrayIndex[ GEF_Snelheid ] = 0; /// Simly a placeholder. WhiteColor = class'Canvas'.static.MakeColor(255,255,225); BlackColor = class'Canvas'.static.MakeColor(20,20,20); BlueColor = class'Canvas'.static.MakeColor(0,0,129); } function int GetMaxLinesVertical(Canvas C) { local float height; local float imax; local float offsety; local float multiplier; /// grid size: multiplier = 24; offsety = 0.114 + 0.15; /// Calculate the maximum amount of numbers, for the resolution: /// Height of the grid: /// using magicx numbers :+ height = ((self.WinHeight - offsety) * C.SizeY) ; /// steps of multiplier imax = height / multiplier; ///Log("height: " @ height @ " - " @ imax @ "- " @ self.WinHeight); return imax; } function bool OnDraw(Canvas C) { local int index; Super.OnDraw(C); C.DrawColor = WhiteColor; C.Font = SmallFont; maxlinesvertical = GetMaxLinesVertical(C); /// Draw grid: DrawGrid(C); /// Draw depth nr's DrawDepths(C); DrawBlueBoxes(C); DrawCaptionAndUnit(C, false); /// Line around everything: C.SetPos(self.WinLeft*C.SizeX, self.WinTop * C.SizeY); C.DrawBox(C, self.WinWidth *C.SizeX , self.WinHeight * C.SizeY); C.DrawColor = Colors[StatsType1]; index = ArrayIndex[StatsType1]; // Log(StatsType1 @ " - " @ index); DrawVerticalLine(C); /// Draw the graph. DrawGraph(C, index, false ); DrawGraphHeaders(C, index, false); /// Draw values: DrawCurrentValueBox(C, false); //DrawValueBar(C,false); /// Second graph? if (StatsType2 != GEF_NONE) { /// Only display graph when needed: if (BottomType == FORMAT_GRAPH) { C.DrawColor = WhiteColor; C.Font = SmallFont; DrawCaptionAndUnit(C, true); C.DrawColor = Colors[StatsType2]; index = ArrayIndex[StatsType2]; /// Draw the graph. DrawGraph(C, index, true); /// Draw values: DrawCurrentValueBox(C, true); /// Draw bottom headers: DrawGraphHeaders(C, index, true); } else { /// Display depth in a large font: if (sondeertime <= GEFLines) { DrawDepthCaption(C); } } } //Log("on draw"); return true; } /// Draw grid: function DrawGrid(Canvas C) { local float topoffset; local float bottomoffset; topoffset = 0.111; //tempoffset; // 0.10; bottomoffset = 0.12; //.2; TileGrid(C, Texture'sondeermeester.sondeergrid', self.WinLeft*C.sizex, (self.Wintop + topoffset) * C.sizeY, 10, 17); /// Draw grid layer: //C.SetPos(self.WinLeft*C.SizeX, ((self.WinTop) * C.SizeY) + 96 ); //C.DrawPattern ( Texture'sondeermeester.sondeergrid', self.WinWidth * C.SizeX , (self.WinHeight - bottomoffset) * C.SizeY, 1); } /// Custom tiling function, test. function TileGrid(Canvas C, Texture tex, float fx, float fy, int tilesx, int tilesy) { local int x, y; local float bottomoffset; local float height; local int divider; local float startindex; local float imaxresy; local float maxrowsheight; local int shift; // local float iheight; divider = 25; bottomoffset = 0.11; height = (self.WinHeight - bottomoffset) * C.SizeY ; // iheight = ((self.WinHeight - bottomoffset) * C.SizeY) - 8 ; /// steps of multiplier imaxresy = maxlinesvertical; //iheight / divider; tilesx = ((self.WinWidth * C.SizeX) / divider) + 1; tilesy = imaxresy + 4; //height / divider; tilesy += int(startindex / 4); C.DrawColor = color_background; C.SetPos(fx, fy); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', self.WinWidth * C.SizeX , height); C.DrawColor = color_lines; startindex = 0; // log( topvalues.length @ "- " @ imaxresy); if (topvalues.length > (imaxresy * 10)) startindex = topvalues.length - (imaxresy * 10); for (x = 0; x < tilesx; x++) { C.SetPos(fx + (x * divider), self.WinTop * C.SizeY ); c.DrawLine(1, self.WinHeight * C.SizeY); //up } maxrowsheight = ((self.WinHeight + self.WinTop) - 0.08) * c.SizeY; shift = (startindex % 9) * 3; for (y = 0; y < tilesy + 1; y++) // + (startindex / 5) { C.SetPos(self.WinLeft * C.SizeX, (fy + (y * divider)) - shift); //- (startindex*2.5) c.DrawLine(3, self.WinWidth * C.SizeX); //right /// Break if getting below graph space: //if ((fy + (y * divider) - (startindex*2.5)) > maxrowsheight) //{ // break; // } } C.DrawColor = Whitecolor; } function DrawBlueBoxes(Canvas C) { local float boxheight; boxheight = 0.09; C.DrawColor = BoxColor; /// Draw rectangle at top: C.SetPos(self.WinLeft*C.SizeX, self.WinTop * C.SizeY); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', self.WinWidth *C.SizeX , boxheight * C.SizeY); /// Draw rectangle at bottom: C.SetPos(self.WinLeft*C.SizeX, ((self.WinTop + self.WinHeight) - boxheight) * C.SizeY); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', self.WinWidth * C.SizeX , boxheight * C.SizeY); C.DrawColor = Whitecolor; } function DrawCaptionAndUnit(Canvas C, bool bottom) { local float topoffset; local float bottomoffset; local float leftoffset; leftoffset = 0.01; bottomoffset = 0.05; topoffset = 0.01; if (bottom == false) { /// Draw caption text: C.SetPos((self.WinLeft + leftoffset )*C.SizeX, (self.WinTop+topoffset) * C.SizeY); C.DrawText(LabelTop); /// And unit: C.SetPos((self.WinLeft + leftoffset)*C.SizeX, (self.WinTop+topoffset+0.02) * C.SizeY); C.DrawText("[" $ LabelTopUnit $ "]"); } else { /// Draw caption text: C.SetPos((self.WinLeft + leftoffset)*C.SizeX, ((self.WinTop+self.WinHeight)-bottomoffset) * C.SizeY); C.DrawText(LabelBottom); /// And unit: C.SetPos((self.WinLeft + leftoffset)*C.SizeX, ((self.WinTop+self.WinHeight)- (bottomoffset - 0.02)) * C.SizeY); C.DrawText("[" $ LabelBottomUnit $ "]"); } } function UpdateData(int time, bool bottom, optional bool usecustom, optional float customvalue) { local PlayerController pc; local int i; // local int c; // local int ypos; local SondeerLocation sl; local array strsplit1; local float f1; local int iArrayIndex; local float fMaxValue, fMinValue; // local float graphmultiplier; if (usecustom == false) { if (bottom == false) iArrayIndex = ArrayIndex[StatsType1]; if (bottom == true) { if (StatsType2 == GEF_NONE) return; iArrayIndex = ArrayIndex[StatsType2]; } } /// Get active sondeerlocation: pc = PlayerOwner(); sl = GeoPlayercontroller(PC).CurrentSondeerLocation; fMinValue = rangetop.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangetop.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); if (Bottom == true) { fMinValue = rangebottom.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangebottom.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); } SondeerTime = time; i = sondeertime; if (sondeertime <= GEFLines) { /// Not using custom values? if (usecustom == false) { strsplit1 = Split(sl.data[i], " "); f1 = float(strsplit1[iArrayIndex]); /// Store current depth: CurrentDepth = float(strsplit1[ ArrayIndex[ GEF_Diepte ] ]); GeoPC.playeractions.SondeerDepth = CurrentDepth; /// Convert? if (iArrayIndex == 4) { if (WaterSpanningToKPA == true) { f1 *= 1000; //f2 *= 1000; } } } else { /// jln - 01-10-2008 DO use custom values. f1 = customvalue; } if (bottom == false) { // Log("update: " @ iArrayIndex @ " - " @ topdisplacement); f1 *= topdisplacement; } else { f1 *= bottomdisplacement; } /// Clamp to graph limits: f1 = FClamp(f1, fMinValue, fMaxValue); //f2 = FClamp(f2, fMinValue, fMaxValue); if (Bottom==false) { topvalues.Length = sondeertime; topvalues[sondeertime] = f1; CurrentValue = (f1); } else { bottomvalues.Length = sondeertime; bottomvalues[sondeertime] = f1; BottomValue = f1; } } } /// Draw current depth in the bottom left corner: function DrawDepthCaption(Canvas C) { //local PlayerController pc; //local SondeerLocation sl; //local array strsplit2; C.DrawColor = WhiteColor; C.Font = LargeFont; /// Get data: //pc = PlayerOwner(); //sl = GeoPlayercontroller(PC).CurrentSondeerLocation; //strsplit2 = Split(sl.data[sondeertime], " "); //if (strsplit2.Length > 7) //{ BottomValue = float(sondeertime) / 10; //} /// And unit: C.SetPos(self.WinLeft + (self.WinWidth / 2) * C.SizeX, ((self.WinTop+self.WinHeight)-0.07) * C.SizeY); C.DrawText(BottomValue); } /// jln - 15-08-2008 Draw graph column headers function DrawGraphHeaders(Canvas C, int ArrayIndex, optional bool Bottom) { local float fMaxValue, fMinValue; local float fI; local float step; local float LX, LY; local int i; // local float boxwidth, boxheight; local float topoffset, bottomoffset; topoffset = 0.068; bottomoffset = 0.08; /// Determine starting position: LX = ((self.WinLeft ) * c.SizeX) + 5; LY = ((self.WinTop + topoffset) * c.SizeY); if (Bottom == true) { LY = (((self.WinHeight + self.WinTop) - bottomoffset) * c.SizeY); } C.Font = SmallFont; /// Get graph borders: fMinValue = rangetop.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangetop.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); if (Bottom == true) { fMinValue = rangebottom.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangebottom.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); } fI = fMinValue; step = (abs(fMinValue) + fMaxValue) / 5; //Log("step: " @ step @ " - " @ fMinValue @ " - " @ fMaxValue); for (i = 0; i < 6; i++) { //C.strlen(fi, outx, outy); if (Len(int(fi)) > 3) { c.SetPos( LX + (((self.WinWidth/6)*i) * C.SizeX), LY); } else { c.SetPos( LX + (((self.WinWidth/6)*i) * C.SizeX), LY); } if (fMaxValue < 2) { c.DrawText(fI); } else { c.DrawText(int(fI)); } fI += (step); } } function DrawVerticalLine(Canvas MyCanvas) { local color GraphColor; if (_verticalline.left != 0 && _verticalline.top != 0) { GraphColor = MyCanvas.Drawcolor; MyCanvas.DrawColor = WhiteColor; DrawLine(MyCanvas, _verticalline.left , _verticalline.top, _verticalline.right , _verticalline.bottom ); MyCanvas.DrawColor = GraphColor; } } function DrawGraph(Canvas MyCanvas, int iArrayIndex, bool bottom) { local PlayerController pc; local int i; local int c; local int ypos; local SondeerLocation sl; // local array strsplit1; // local array strsplit2; // local float f1; local float LX; local float LY; local float fMaxValue, fMinValue; local color GraphColor; local float graphmultiplier; local int startindex; local float tmp1, tmp2; GraphColor = MyCanvas.Drawcolor; // tempoffset = tempoffset - 0.0001; // Log(tempoffset); /// Calculate graph // fMinValue = float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); // fMaxValue = float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); /// Get graph borders: fMinValue = rangetop.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangetop.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); if (Bottom == true) { fMinValue = rangebottom.rangestart; // float(Localize("Sondering1","typemin" $ arrayindex,"Sondering1")); fMaxValue = rangebottom.rangeend; //float(Localize("Sondering1","typemax" $ arrayindex,"Sondering1")); } graphmultiplier = ((self.WinWidth * MyCanvas.SizeX)-2) / (abs(fMinValue) + fMaxValue); // if (bottom==true) // { // Log(fMinValue @ " - "@ fMaxValue); // } //Log("Conus multiplier: " @ conusmultiplier); //local StaticMeshActor duck; pc = PlayerOwner(); sl = GeoPlayercontroller(PC).CurrentSondeerLocation; LX = self.WinLeft * MyCanvas.SizeX + 0.01 + abs((fMinValue-0) * graphmultiplier) + 2; LY = (self.WinTop + 0.115) * MyCanvas.SizeY; c = 0; /// Draw second line if fMinvalue is not 0, displaying an additional 0 mark line: if (fMinValue != 0) { tmp1 = (((self.WinTop+self.WinHeight) - 0.08) * MyCanvas.SizeY)-4; tmp2 = LY-8; /// Store values: /// We need to render the bar somewhere else: _verticalline.left = LX; _verticalline.top = tmp1; _verticalline.right = LX; _verticalline.bottom = tmp2; MyCanvas.DrawColor = GraphColor; } ypos = (LY); startindex = 0; if (topvalues.length > (maxlinesvertical * 10)) startindex = topvalues.length - (maxlinesvertical * 10); if (Bottom==false) { for (i = startindex; i < topvalues.length-1; i++) { DrawLine(MyCanvas, LX + (topvalues[i]*graphmultiplier), ypos+( (i-startindex) * 2.5), LX + (topvalues[i+1]*graphmultiplier), (ypos+( ( (i-startindex) +1)*2.5))); } if (i < topvalues.length) { DrawValueBar(MyCanvas, bottom, LX, (topvalues[i]*graphmultiplier)); } else { DrawValueBar(MyCanvas, bottom, LX, 0); } } else { for (i = startindex; i < bottomvalues.length-1; i++) { DrawLine(MyCanvas, LX + (bottomvalues[i]*graphmultiplier), ypos+( (i-startindex) *2.5), LX + (bottomvalues[i+1]*graphmultiplier), (ypos+(( (i-startindex) +1)*2.5))); } // also render bottom one? if (Bottom == true) { if (i < bottomvalues.length) { DrawValueBar(MyCanvas, true, LX, (bottomvalues[i]*graphmultiplier), (STATSType2 == GEF_None || BottomType == FORMAT_TEXTONLY) ); } else { DrawValueBar(MyCanvas, true, LX, 0, (STATSType2 == GEF_None || BottomType == FORMAT_TEXTONLY) ); } } } MyCanvas.DrawColor = WhiteColor; } /// jln - 15-08-2008 Draw depths function DrawDepths(Canvas c) { local int i, j; local float LX, LY; local float offsetx, offsety, multiplier; local float startindex; local int counter; // local float outx, outy; local int imaxresy; local float height; //local float shift; offsetx = 0.0; offsety = 0.112; multiplier = 24; LX = ((self.WinLeft + self.WinWidth ) * c.SizeX) - 22 ; LY = ((self.WinTop + offsety) * c.SizeY) + 6; /// Draw the vertical list of depth. /// Calculate the maximum amount of numbers, for the resolution: /// Height of the grid: /// using magicx numbers :+ height = (((self.WinHeight - 0.15) - offsety) * C.SizeY) - 8 ; /// steps of multiplier imaxresy = maxlinesvertical + (startindex / 25); // height / multiplier; startindex = 0; if (topvalues.length > (imaxresy*10)) startindex = (topvalues.length - (imaxresy*10)); // / 10; //(topvalues.length - 170) / 10 ; j = 0; startindex = startindex - 1; for (i = (startindex/10); i < (MaxDepth+1); i++) { // c.SetPos( LX , LY + ( (i-startindex) * multiplier) - (startindex * 3)); //C.strlen(i, outx, outy); c.SetPos( LX , (LY + (counter * multiplier)) - ((startindex%10)*3) ); c.DrawText(i ); if (j > imaxresy ) break; j++; counter++; } } /// jln - 15-08-2008 Draws a box displaying current value function DrawCurrentValueBox(Canvas c, optional bool Bottom, optional bool Empty) { local float boxwidth, boxheight; local float topoffset, bottomoffset; local float boxleft; boxwidth = 0.08; boxheight = 0.04; topoffset = 0.01; bottomoffset = 0.06; boxleft = ((self.WinLeft+self.WinWidth) - boxwidth) - 0.01; C.Font = SmallFont; if (Bottom == false) { /// Line around everything: C.SetPos( boxleft * C.SizeX, (self.WinTop + topoffset) * C.SizeY); C.DrawBox(C, boxwidth *C.SizeX , boxheight * C.SizeY); if (Empty == false) { /// Draw current value: C.SetPos( (boxleft * C.SizeX) + 10, (self.WinTop + topoffset + 0.0078) * C.SizeY); C.DrawText( CurrentValue); } } else { /// Line around everything: C.SetPos( boxleft * C.SizeX, ((self.WinTop + self.WinHeight - bottomoffset) + topoffset) * C.SizeY); C.DrawBox(C, boxwidth *C.SizeX , boxheight * C.SizeY); if (Empty == false) { C.SetPos( (boxleft * C.SizeX) + 10, (self.WinTop + self.WinHeight - bottomoffset + topoffset + 0.0078) * C.SizeY); C.DrawText( BottomValue); } } } /// Creates the "Progress bar" at the top and bottom of the column. function DrawValueBar(Canvas C, bool bottom, float leftmargin, float width, optional bool Empty) { local float boxwidth, boxheight; local float topoffset, bottomoffset; // local float converted; local color currentcolor; boxwidth = self.WinWidth; boxheight = 0.02; topoffset = 0.09; bottomoffset = 0.11; /// Do not draw negative values: //if (width < 0) return; if (bottom == false) { currentcolor = C.DrawColor; /// Draw fill first: C.SetPos( self.WinLeft * C.SizeX , (self.WinTop + topoffset) * C.SizeY); C.DrawColor = class'Canvas'.static.MakeColor(128,128,128, 255); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', self.WinWidth * C.SizeX , boxheight * C.SizeY); /// Set color again: C.DrawColor = currentcolor; if (Empty == false) { if (width > 0) { C.SetPos( leftmargin , (self.WinTop + topoffset) * C.SizeY); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', width - 4 , boxheight * C.SizeY); } } C.DrawColor = class'Canvas'.static.MakeColor(255,255,255, 255); C.SetPos( self.WinLeft * C.SizeX , (self.WinTop + topoffset) * C.SizeY); C.DrawBox(C, (boxwidth *C.SizeX) , boxheight * C.SizeY); } else { /// Botttom: currentcolor = C.DrawColor; /// Draw fill first: C.SetPos( self.WinLeft * C.SizeX , (self.WinTop +self.WinHeight - bottomoffset) * C.SizeY); C.DrawColor = class'Canvas'.static.MakeColor(128,128,128, 255); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', self.WinWidth * C.SizeX , boxheight * C.SizeY); /// Set color again: C.DrawColor = currentcolor; if (Empty == false) { if (width > 0) { C.SetPos( leftmargin , (self.WinTop+self.WinHeight - bottomoffset) * C.SizeY); C.DrawTileStretched ( Texture'sondeermeester.whitesquare', width - 4 , boxheight * C.SizeY); } } C.DrawColor = class'Canvas'.static.MakeColor(255,255,255, 255); C.SetPos( self.WinLeft * C.SizeX , (self.WinTop+self.WinHeight - (bottomoffset)) * C.SizeY); C.DrawBox(C, (boxwidth *C.SizeX) , boxheight * C.SizeY); } } /** str = input string div = divider **/ function array Split(string str, string div) { local array temp; local bool bEOL; local string tempChar; local int precount, curcount, wordcount, strLength; local int i; strLength = len(str); bEOL = false; precount = 0; curcount = 0; wordcount = 0; i = 0; if (strLength == 0) return temp; while(!bEOL) { tempChar = Mid(str, curcount, 1); //go up by 1 count if(tempChar != div) curcount++; else if(tempChar == div) { temp[wordcount] = Mid(str, precount, curcount-precount); wordcount++; precount = curcount + 1; //removes the divider. curcount++; } if(curcount == strLength)//end of string, flush out the final word. { temp[wordcount] = Mid(str, precount, curcount); bEOL = true; } /// Bail out if we get high numbers: // if (i > 500) bEOL = true; i++; } return temp; } /// Draw line on the canvas: function DrawLine(Canvas c, int x1, int y1, int x2, int y2) { local int deltax; // The difference in the x's local int deltay; // The difference in the y's local int y; // Start y off at the first pixel value local int ynum; // The starting value for the numerator local int x; local int prevx; local int prevy; local int xinc1; local int xinc2; local int yinc1; local int yinc2; local int den; local int num; local int numadd; local int numpixels; local int curpixel; curpixel = 0; deltax = abs(x2 - x1); deltay = abs(y2 - y1); y = y1; x = x1; ynum = deltax / 2; prevx = x1; prevy = y; if (x2 >= x1) // The x-values are increasing { xinc1 = 1; xinc2 = 1; } else // The x-values are decreasing { xinc1 = -1; xinc2 = -1; } if (y2 >= y1) // The y-values are increasing { yinc1 = 1; yinc2 = 1; } else // The y-values are decreasing { yinc1 = -1; yinc2 = -1; } if (deltax >= deltay) // There is at least one x-value for every y-value { xinc1 = 0; // Don't change the x when numerator >= denominator yinc2 = 0; // Don't change the y for every iteration den = deltax; num = deltax / 2; numadd = deltay; numpixels = deltax; // There are more x-values than y-values } else // There is at least one y-value for every x-value { xinc2 = 0; // Don't change the x for every iteration yinc1 = 0; // Don't change the y when numerator >= denominator den = deltay; num = deltay / 2; numadd = deltax; numpixels = deltay; // There are more y-values than x-values } for (curpixel = 0; curpixel <= numpixels; curpixel++) { c.SetPos( x, y); c.DrawLine(0, 1); //up num += numadd; // Increase the numerator by the top of the fraction prevx = x; prevy = y; if (num >= den) // Check if numerator >= denominator { num -= den; // Calculate the new numerator value x += xinc1; // Change the x as appropriate y += yinc1; // Change the y as appropriate } x += xinc2; // Change the x as appropriate y += yinc2; // Change the y as appropriate } } function InternalOnChange(GUIComponent Sender) { OnChange(self); } defaultproperties { Begin Object Class=GeoFrame name=TDialogBackground WinLeft=0 WinTop=0 WinWidth=1 WinHeight=1 End Object SmallFont=Font'GeoFonts.SmallFontTex2' MediumFont=Font'GeoFonts.NormalFontTex2' LargeFont=Font'GeoFonts.LargeFontTex2' WinWidth=0.241 WinHeight=0.775 WinLeft=0.05 WinTop=0.05 bTabStop=true PropagateVisibility=true bVisible=true RenderWeight=1 }