mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
more flexible single player screen updating upon map selection
This commit is contained in:
@@ -1,14 +1,23 @@
|
|||||||
--playerListboxPos = {x = 210, y = 100, z = 0}
|
|
||||||
Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z}
|
Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z}
|
||||||
Size = {x = 100, y = 20}
|
Size = {x = 100, y = 20}
|
||||||
|
difficulties = {"Easy", "Medium", "Hard"}
|
||||||
|
space = 10
|
||||||
|
|
||||||
gui = {
|
gui = {
|
||||||
{
|
{
|
||||||
pos = {x = Pos.x, y = Pos.y + (#factions * Size.y + 10) * (lineId + 1), z = Pos.z},
|
pos = {x = Pos.x, y = Pos.y + (#factions * Size.y + space) * (lineId + 1), z = Pos.z},
|
||||||
size = Size,
|
size = Size,
|
||||||
guiType = GuiType.LISTBOX,
|
guiType = GuiType.LISTBOX,
|
||||||
numMaxDisplay = 3,
|
numMaxDisplay = 3,
|
||||||
lines = factions,
|
lines = factions,
|
||||||
listboxType = ListboxType.FACTIONS
|
listboxType = ListboxType.FACTIONS
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x + space, y = Pos.y + (#difficulties * Size.y + space) * (lineId + 1), z = Pos.z},
|
||||||
|
size = Size,
|
||||||
|
guiType = GuiType.LISTBOX,
|
||||||
|
numMaxDisplay = 3,
|
||||||
|
lines = difficulties,
|
||||||
|
listboxType = ListboxType.CPU_DIFFICULTIES
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,7 +389,6 @@ namespace battleship{
|
|||||||
listbox = new LandTextureListbox(pos, size, lines, maxDisplay, fontPath);
|
listbox = new LandTextureListbox(pos, size, lines, maxDisplay, fontPath);
|
||||||
break;
|
break;
|
||||||
case CPU_DIFFICULTIES:
|
case CPU_DIFFICULTIES:
|
||||||
lines = vector<string>{"Easy", "Medium", "Hard"};
|
|
||||||
numLines = lines.size();
|
numLines = lines.size();
|
||||||
closable = true;
|
closable = true;
|
||||||
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
|
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
|
||||||
@@ -397,7 +396,6 @@ namespace battleship{
|
|||||||
listbox = new Listbox(pos, size, lines, maxDisplay, fontPath);
|
listbox = new Listbox(pos, size, lines, maxDisplay, fontPath);
|
||||||
break;
|
break;
|
||||||
case FACTIONS:
|
case FACTIONS:
|
||||||
//lines = vector<string>{"America inc.", "European Republic", "Asian Co-Prosperity Sphere"};
|
|
||||||
numLines = lines.size();
|
numLines = lines.size();
|
||||||
closable = true;
|
closable = true;
|
||||||
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
|
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
|
||||||
|
|||||||
+9
-2
@@ -21,6 +21,8 @@ namespace battleship{
|
|||||||
MapListbox::MapListbox(Vector3 pos, Vector2 size, std::vector<string> &lines, int maxDisplay, bool adg, string fontPath, bool closeable) :
|
MapListbox::MapListbox(Vector3 pos, Vector2 size, std::vector<string> &lines, int maxDisplay, bool adg, string fontPath, bool closeable) :
|
||||||
Listbox(pos, size, lines, maxDisplay, fontPath, closeable),
|
Listbox(pos, size, lines, maxDisplay, fontPath, closeable),
|
||||||
addPlayerGui(adg) {
|
addPlayerGui(adg) {
|
||||||
|
openUp();
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapListbox::onClose(){
|
void MapListbox::onClose(){
|
||||||
@@ -36,12 +38,17 @@ namespace battleship{
|
|||||||
int numSpawnPoints = Map::getSingleton()->getNumMapSpawnPoints(mapName);
|
int numSpawnPoints = Map::getSingleton()->getNumMapSpawnPoints(mapName);
|
||||||
sol::state_view SOL_LUA_VIEW = generateView();
|
sol::state_view SOL_LUA_VIEW = generateView();
|
||||||
|
|
||||||
for(int i = 0; i < numSpawnPoints; i++){
|
for(int i = 0; i < numSpawnPoints - 1; i++){
|
||||||
|
int prevNumListboxes = guiManager->getListboxes().size();
|
||||||
|
|
||||||
SOL_LUA_VIEW.script("lineId = " + to_string(i));
|
SOL_LUA_VIEW.script("lineId = " + to_string(i));
|
||||||
guiManager->parseLuaScript("playerSelection.lua");
|
guiManager->parseLuaScript("playerSelection.lua");
|
||||||
|
|
||||||
std::vector<Listbox*> listboxes = guiManager->getListboxes();
|
std::vector<Listbox*> listboxes = guiManager->getListboxes();
|
||||||
cpuPlayerListboxes.push_back(listboxes[listboxes.size() - 1]);
|
int diffNumListboxes = guiManager->getListboxes().size() - prevNumListboxes;
|
||||||
|
|
||||||
|
for(int j = 0; j < diffNumListboxes; j++)
|
||||||
|
cpuPlayerListboxes.push_back(listboxes[listboxes.size() - 1 - j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user