From 0fcec2834ea89ae26f636e5686fba4c4cba3fba4 Mon Sep 17 00:00:00 2001 From: johns <> Date: Mon, 4 Jun 2001 13:47:43 +0000 Subject: [PATCH] CleanUserInterface and LoadUserInterface function added. --- src/ui/ui.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 9e49de866..3f9747680 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -381,13 +381,11 @@ global void InitUserInterface(void) { int i; int best; - // FIXME: this should be configurable - static const char* names[]={ "human","orc","alliance","mythical" }; // select the correct slot best=0; for( i=0; UI_Table[i]; ++i ) { - if( !strcmp(names[(ThisPlayer->Race+RaceAdd*2)&3],UI_Table[i]->Name) ) { + if( !strcmp(ThisPlayer->RaceName,UI_Table[i]->Name) ) { // perfect if( VideoWidth==UI_Table[i]->Width && VideoHeight==UI_Table[i]->Height ) { @@ -410,6 +408,20 @@ global void InitUserInterface(void) // FIXME: overwrites already set slots? TheUI=*UI_Table[best]; + // + // Calculations + // + MapWidth=(TheUI.MapEndX-TheUI.MapX+TileSizeX)/TileSizeX; + MapHeight=(TheUI.MapEndY-TheUI.MapY+TileSizeY)/TileSizeY; +} + +/** +** Load the user interface graphics. +*/ +global void LoadUserInterface(void) +{ + int i; + // // Load graphics // @@ -454,7 +466,7 @@ global void InitUserInterface(void) } // - // Cursors. + // Resolve cursors // TheUI.Point.Cursor=CursorTypeByIdent(TheUI.Point.Name); TheUI.Glass.Cursor=CursorTypeByIdent(TheUI.Glass.Name); @@ -472,12 +484,37 @@ global void InitUserInterface(void) TheUI.ArrowSW.Cursor=CursorTypeByIdent(TheUI.ArrowSW.Name); TheUI.ArrowS.Cursor=CursorTypeByIdent(TheUI.ArrowS.Name); TheUI.ArrowSE.Cursor=CursorTypeByIdent(TheUI.ArrowSE.Name); +} + +/** +** Clean up the user interface module. +*/ +global void CleanUserInterface(void) +{ + int i; // - // Calculations + // Free the graphics. FIXME: if shared this crashs. // - MapWidth=(TheUI.MapEndX-TheUI.MapX+TileSizeX)/TileSizeX; - MapHeight=(TheUI.MapEndY-TheUI.MapY+TileSizeY)/TileSizeY; + VideoSaveFree(TheUI.Filler1.Graphic); + VideoSaveFree(TheUI.Resource.Graphic); + + for( i=0; i<MaxCosts; ++i ) { + VideoSaveFree(TheUI.Resources[i].Icon.Graphic); + } + + VideoSaveFree(TheUI.FoodIcon.Graphic); + VideoSaveFree(TheUI.ScoreIcon.Graphic); + VideoSaveFree(TheUI.InfoPanel.Graphic); + VideoSaveFree(TheUI.ButtonPanel.Graphic); + VideoSaveFree(TheUI.MenuButton.Graphic); + VideoSaveFree(TheUI.Minimap.Graphic); + VideoSaveFree(TheUI.StatusLine.Graphic); + + memset(&TheUI,0,sizeof(TheUI)); + + + DebugLevel0Fn("FIXME: not complete written\n"); } //@}