diff --git a/Assets/Scripts/Core/main.lua b/Assets/Scripts/Core/main.lua index 3c1fdea..7192bf6 100644 --- a/Assets/Scripts/Core/main.lua +++ b/Assets/Scripts/Core/main.lua @@ -1,4 +1,6 @@ game = {cpuPlayers = {}} +_minimapPos = {x = 0, y = 0} +_minimapSize = {x = 0, y = 0} GameObjectFrameStatus = { PLACEABLE = 0, BLOCKED_BY_FOG_OF_WAR = 1, diff --git a/Assets/Scripts/Gui/activeGameState.lua b/Assets/Scripts/Gui/activeGameState.lua index 99ed904..df197a5 100644 --- a/Assets/Scripts/Gui/activeGameState.lua +++ b/Assets/Scripts/Gui/activeGameState.lua @@ -43,12 +43,18 @@ noSupplyTex = 'noSupply.png' noHackTex = 'noHack.png' gui = { + { + guiType = GuiType.GUI_RECTANGLE, + pos = {x = minimapPos.x, y = minimapPos.y, z = .8}, + size = minimapSize, + color = {x = .5, y = .5, z = .5, w = .6} + }, { guiType = GuiType.BUTTON, buttonType = ButtonType.MINIMAP, name = 'minimap', - pos = minimapPos, - size = minimapSize, + pos = {x = _minimapPos.x, y = minimapPos.y + _minimapPos.y, z = minimapPos.z}, + size = {x = _minimapSize.x, y = _minimapSize.y}, color = {x = .5, y = .5, z = .5, w = 1} }, { @@ -116,8 +122,10 @@ gui = { }, { guiType = GuiType.GUI_RECTANGLE, - pos = {x = minimapPos.x, y = res.y - .75 * sz, z = 0}, + pos = {x = minimapSize.x, y = res.y - .75 * sz, z = 0}, size = {x = res.x - minimapPos.x, y = sz * .75}, color = {x = .6, y = .6, z = .6, w = .4} }, + --[[ + ]]-- } diff --git a/activeGameState.cpp b/activeGameState.cpp index bb991f4..7c7b698 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -123,6 +123,27 @@ namespace battleship{ vector buttons = guiButtons; buttons.insert(buttons.end(), unitButtons.begin(), unitButtons.end()); + Vector3 mapSize = Map::getSingleton()->getMapSize(); + float ratio = mapSize.x / mapSize.z; + + sol::state_view SOL_LUA_VIEW = generateView(); + SOL_LUA_VIEW.script_file(GameManager::getSingleton()->getPath() + "Scripts/Gui/activeGameState.lua"); + sol::table sizeTbl = SOL_LUA_VIEW["minimapSize"]; + float initSizeX = sizeTbl["x"], initSizeY = sizeTbl["y"]; + + if(ratio < 1){ + float x = initSizeX * ratio; + SOL_LUA_VIEW["_minimapPos"]["x"] = .5 * (initSizeX - x) ; + SOL_LUA_VIEW["_minimapSize"]["x"] = x; + SOL_LUA_VIEW["_minimapSize"]["y"] = initSizeY; + } + else{ + float y = initSizeY / ratio; + SOL_LUA_VIEW["_minimapPos"]["y"] = .5 * (initSizeY - y); + SOL_LUA_VIEW["_minimapSize"]["x"] = initSizeX; + SOL_LUA_VIEW["_minimapSize"]["y"] = y; + } + ConcreteGuiManager::getSingleton()->readLuaScreenScript( "activeGameState.lua", buttons, diff --git a/map.cpp b/map.cpp index 21e2495..b625483 100755 --- a/map.cpp +++ b/map.cpp @@ -501,8 +501,6 @@ namespace battleship{ sol::table civPlayerTbl = SOL_LUA_VIEW[mapTable]["civilianPlayer"]; loadPlayerGameObjects(game->getCivilianPlayer(), civPlayerTbl); - - Minimap::getSingleton()->load(); } void Map::preprareScene(bool empty){ @@ -678,6 +676,8 @@ namespace battleship{ for(int i = 0; i < numWaterbodies; i++) loadTerrainObject(i); + + Minimap::getSingleton()->load(); } void Map::create(string mapName, Vector3 mapSize){