NONE removed from players' faction listbox

This commit is contained in:
devZoGok
2026-06-16 19:38:00 +03:00
parent fadf8f3375
commit e3312f5732
3 changed files with 26 additions and 9 deletions
+14 -5
View File
@@ -1,10 +1,19 @@
playerListboxPos = {x = 110, y = 10, z = 0} playerListboxPos = {x = 110, y = 10, z = 0}
Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z} Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z}
FactionListboxSize = {x = 270, y = 20}
Size = {x = 150, y = 20} Size = {x = 150, y = 20}
gap = 10 gap = 10
gapFactor = 3 gapFactor = 3
factions = {'None', 'Asian Co-Prosperity Sphere', 'America inc.', 'European Republic'} function generateFactions(humanPlayer)
factions = {'None', 'Asian Co-Prosperity Sphere', 'America inc.', 'European Republic'}
if humanPlayer then table.remove(factions, 1) end
return factions
end
factions = generateFactions(lineId == MAIN_PLAYER_ID)
difficulties = {"Easy", "Medium", "Hard"} difficulties = {"Easy", "Medium", "Hard"}
colors = {'White', 'Black', 'Red'} colors = {'White', 'Black', 'Red'}
teams = {'0', '1', '2', '3', '4'} teams = {'0', '1', '2', '3', '4'}
@@ -12,7 +21,7 @@ teams = {'0', '1', '2', '3', '4'}
gui = { gui = {
{ {
pos = {x = Pos.x, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, pos = {x = Pos.x, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z},
size = Size, size = FactionListboxSize,
guiType = GuiType.LISTBOX, guiType = GuiType.LISTBOX,
name = 'factions', name = 'factions',
numMaxDisplay = 3, numMaxDisplay = 3,
@@ -20,7 +29,7 @@ gui = {
listboxType = ListboxType.FACTIONS listboxType = ListboxType.FACTIONS
}, },
{ {
pos = {x = Pos.x + Size.x + gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, pos = {x = Pos.x + FactionListboxSize.x + gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z},
size = Size, size = Size,
guiType = GuiType.LISTBOX, guiType = GuiType.LISTBOX,
name = 'difficulties', name = 'difficulties',
@@ -29,7 +38,7 @@ gui = {
listboxType = ListboxType.CPU_DIFFICULTIES listboxType = ListboxType.CPU_DIFFICULTIES
}, },
{ {
pos = {x = Pos.x + 2 * (Size.x + gap), y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, pos = {x = Pos.x + FactionListboxSize.x + Size.x + 2 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z},
size = Size, size = Size,
guiType = GuiType.LISTBOX, guiType = GuiType.LISTBOX,
name = 'colors', name = 'colors',
@@ -38,7 +47,7 @@ gui = {
listboxType = ListboxType.COLORS listboxType = ListboxType.COLORS
}, },
{ {
pos = {x = Pos.x + 3 * (Size.x + gap), y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, pos = {x = Pos.x + FactionListboxSize.x + 2 * Size.x + 3 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z},
size = Size, size = Size,
guiType = GuiType.LISTBOX, guiType = GuiType.LISTBOX,
name = 'teams', name = 'teams',
+2
View File
@@ -6,6 +6,8 @@ music = {
tracks = {'intro.ogg'} tracks = {'intro.ogg'}
} }
MAIN_PLAYER_ID = 0
gui = { gui = {
{ {
pos = {x = 110, y = 310, z = 0}, pos = {x = 110, y = 310, z = 0},
+10 -4
View File
@@ -36,15 +36,21 @@ namespace battleship{
int selectedMap = mapListbox->getSelectedOption(); int selectedMap = mapListbox->getSelectedOption();
string mapName = wstringToString(mapListbox->getContents()[selectedMap]); string mapName = wstringToString(mapListbox->getContents()[selectedMap]);
int numPlayers = Map::getSingleton()->getNumMapSpawnPoints(mapName); int numPlayers = Map::getSingleton()->getNumMapSpawnPoints(mapName);
const int MAIN_PLAYER_ID = (int)generateView()["MAIN_PLAYER_ID"];
for(int i = 0; i < numPlayers; i++){ for(int i = 0; i < numPlayers; i++){
int factionChoice = factionsListboxes[i]->getSelectedOption(); int faction = factionsListboxes[i]->getSelectedOption();
bool cpuPlayer;
if(factionChoice == 0) continue; if(factionsListboxes[i]->getContents()[faction] == L"None") continue;
int faction = factionChoice - 1; if(MAIN_PLAYER_ID == i)
cpuPlayer = false;
else{
faction--;
cpuPlayer = true;
}
bool cpuPlayer = (i > 0);
string diffStr = (cpuPlayer ? wstringToString(difficultiesListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]) : ""); string diffStr = (cpuPlayer ? wstringToString(difficultiesListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]) : "");
int difficulty = -1; int difficulty = -1;