Skip to content

Commit

Permalink
Update server creation menu with translation markers.
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Mar 8, 2020
1 parent 136db4d commit 90fbe46
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/menus/serverCreationScreen.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <i18n.h>
#include "preferenceManager.h"
#include "serverCreationScreen.h"
#include "shipSelectionScreen.h"
Expand Down Expand Up @@ -48,110 +49,110 @@ ServerCreationScreen::ServerCreationScreen()

// Left column contents.
// General section.
(new GuiLabel(left_panel, "GENERAL_LABEL", "Server configuration", 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(left_panel, "GENERAL_LABEL", tr("Server configuration"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);

// Server name row.
GuiElement* row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "NAME_LABEL", "Server name: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "NAME_LABEL", tr("Server name: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiTextEntry(row, "SERVER_NAME", game_server->getServerName()))->callback([](string text){game_server->setServerName(text);})->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Server password row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "PASSWORD_LABEL", "Server password: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "PASSWORD_LABEL", tr("Server password: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiTextEntry(row, "SERVER_PASSWORD", ""))->callback([](string text){game_server->setPassword(text.upper());})->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Server IP row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "IP_LABEL", "Server IP: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "IP_LABEL", tr("Server IP: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "IP", sf::IpAddress::getLocalAddress().toString(), 30))->setAlignment(ACenterLeft)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// LAN/Internet row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "LAN_INTERNET_LABEL", "Server visibility: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "LAN_INTERNET_LABEL", tr("Server visibility: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "LAN_INTERNET_SELECT", [](int index, string value) {
if (index == 1)
game_server->registerOnMasterServer(PreferencesManager::get("registry_registration_url", "http://daid.eu/ee/register.php"));
else
game_server->stopMasterServerRegistry();
}))->setOptions({"LAN only", "Internet"})->setSelectionIndex(0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);
}))->setOptions({tr("LAN only"), tr("Internet")})->setSelectionIndex(0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Player Ships section.
(new GuiLabel(left_panel, "PLAYER_SHIP_LABEL", "Player ship options", 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(left_panel, "PLAYER_SHIP_LABEL", tr("Player ship options"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);

// Warp/Jump drive row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "WARP_JUMP_LABEL", "Warp/Jump: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "WARP_JUMP_LABEL", tr("Warp/Jump: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "WARP_JUMP_SELECT", [](int index, string value) {
gameGlobalInfo->player_warp_jump_drive_setting = EPlayerWarpJumpDrive(index);
}))->setOptions({"Ship default", "Warp drive", "Jump drive", "Both", "Neither"})->setSelectionIndex((int)gameGlobalInfo->player_warp_jump_drive_setting)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);
}))->setOptions({tr("warp/jump", "Ship default"), tr("warp/jump", "Warp drive"), tr("warp/jump", "Jump drive"), tr("warp/jump", "Both"), tr("warp/jump", "Neither")})->setSelectionIndex((int)gameGlobalInfo->player_warp_jump_drive_setting)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Radar range limit row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "RADAR_LABEL", "Radar range: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "RADAR_LABEL", tr("Radar range: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "RADAR_SELECT", [](int index, string value) {
gameGlobalInfo->long_range_radar_range = index * 5000 + 10000;
}))->setOptions({"10U", "15U", "20U", "25U", "30U", "35U", "40U", "45U", "50U"})->setSelectionIndex((gameGlobalInfo->long_range_radar_range - 10000.0) / 5000.0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Main screen section.
(new GuiLabel(left_panel, "MAIN_SCREEN_LABEL", "Main screen options", 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(left_panel, "MAIN_SCREEN_LABEL", tr("Main screen options"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);

// Radar row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiToggleButton(row, "MAIN_TACTICAL_TOGGLE", "Tactical radar", [](bool value) {
(new GuiToggleButton(row, "MAIN_TACTICAL_TOGGLE", tr("Tactical radar"), [](bool value) {
gameGlobalInfo->allow_main_screen_tactical_radar = value == 1;
}))->setValue(gameGlobalInfo->allow_main_screen_tactical_radar)->setSize(275, GuiElement::GuiSizeMax)->setPosition(0, 0, ACenterLeft);
(new GuiToggleButton(row, "MAIN_LONG_RANGE_TOGGLE", "Long range radar", [](bool value) {
(new GuiToggleButton(row, "MAIN_LONG_RANGE_TOGGLE", tr("Long range radar"), [](bool value) {
gameGlobalInfo->allow_main_screen_long_range_radar = value == 1;
}))->setValue(gameGlobalInfo->allow_main_screen_long_range_radar)->setSize(275, GuiElement::GuiSizeMax)->setPosition(0, 0, ACenterRight);

// Game rules section.
(new GuiLabel(left_panel, "GAME_RULES_LABEL", "Game rules", 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(left_panel, "GAME_RULES_LABEL", tr("Game rules"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);

// Science scan complexity selector.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "GAME_SCANNING_COMPLEXITY_LABEL", "Scan complexity: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "GAME_SCANNING_COMPLEXITY_LABEL", tr("Scan complexity: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "GAME_SCANNING_COMPLEXITY", [](int index, string value) {
gameGlobalInfo->scanning_complexity = EScanningComplexity(index);
}))->setOptions({"None (delay)", "Simple", "Normal", "Advanced"})->setSelectionIndex((int)gameGlobalInfo->scanning_complexity)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);
}))->setOptions({tr("scanning", "None (delay)"), tr("scanning", "Simple"), tr("scanning", "Normal"), tr("scanning", "Advanced")})->setSelectionIndex((int)gameGlobalInfo->scanning_complexity)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Hacking difficulty selector.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "GAME_HACKING_DIFFICULTY_LABEL", "Hacking difficulty: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "GAME_HACKING_DIFFICULTY_LABEL", tr("Hacking difficulty: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "GAME_HACKING_DIFFICULTY", [](int index, string value) {
gameGlobalInfo->hacking_difficulty = index;
}))->setOptions({"Simple", "Normal", "Difficult", "Fiendish"})->setSelectionIndex(gameGlobalInfo->hacking_difficulty)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);
}))->setOptions({tr("Simple", "hacking"), tr("Normal", "hacking"), tr("hacking", "Difficult"), tr("hacking", "Fiendish")})->setSelectionIndex(gameGlobalInfo->hacking_difficulty)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Hacking games selector.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "GAME_HACKING_GAMES_LABEL", "Hacking type: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "GAME_HACKING_GAMES_LABEL", tr("Hacking type: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiSelector(row, "GAME_HACKING_GAME", [](int index, string value) {
gameGlobalInfo->hacking_games = EHackingGames(index);
}))->setOptions({"Mine", "Lights", "All"})->setSelectionIndex((int)gameGlobalInfo->hacking_games)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);
}))->setOptions({tr("hacking", "Mine"), tr("hacking", "Lights"), tr("hacking", "All")})->setSelectionIndex((int)gameGlobalInfo->hacking_games)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);

// Frequency and system damage row.
row = new GuiAutoLayout(left_panel, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiToggleButton(row, "GAME_FREQUENCIES_TOGGLE", "Beam/shield frequencies", [](bool value) {
(new GuiToggleButton(row, "GAME_FREQUENCIES_TOGGLE", tr("Beam/shield frequencies"), [](bool value) {
gameGlobalInfo->use_beam_shield_frequencies = value == 1;
}))->setValue(gameGlobalInfo->use_beam_shield_frequencies)->setSize(275, GuiElement::GuiSizeMax)->setPosition(0, 0, ACenterLeft);

(new GuiToggleButton(row, "GAME_SYS_DAMAGE_TOGGLE", "Per-system damage", [](bool value) {
(new GuiToggleButton(row, "GAME_SYS_DAMAGE_TOGGLE", tr("Per-system damage"), [](bool value) {
gameGlobalInfo->use_system_damage = value == 1;
}))->setValue(gameGlobalInfo->use_system_damage)->setSize(275, GuiElement::GuiSizeMax)->setPosition(0, 0, ACenterRight);

// Right column contents.
// Scenario section.
(new GuiLabel(right_panel, "SCENARIO_LABEL", "Scenario", 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(right_panel, "SCENARIO_LABEL", tr("Scenario"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50);
// List each scenario derived from scenario_*.lua files in Resources.
GuiListbox* scenario_list = new GuiListbox(right_panel, "SCENARIO_LIST", [this](int index, string value) {
selectScenario(value);
Expand All @@ -170,7 +171,7 @@ ServerCreationScreen::ServerCreationScreen()

row = new GuiAutoLayout(variation_container, "", GuiAutoLayout::LayoutHorizontalLeftToRight);
row->setSize(GuiElement::GuiSizeMax, 50);
(new GuiLabel(row, "VARIATION_LABEL", "Variation: ", 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
(new GuiLabel(row, "VARIATION_LABEL", tr("Variation: "), 30))->setAlignment(ACenterRight)->setSize(250, GuiElement::GuiSizeMax);
variation_selection = new GuiSelector(row, "VARIATION_SELECT", [this](int index, string value) {
gameGlobalInfo->variation = variation_names_list.at(index);
variation_description->setText(variation_descriptions_list.at(index));
Expand All @@ -184,14 +185,14 @@ ServerCreationScreen::ServerCreationScreen()

// Buttons beneath the columns.
// Close server button.
(new GuiButton(left_container, "CLOSE_SERVER", "Close server", [this]() {
(new GuiButton(left_container, "CLOSE_SERVER", tr("Close server"), [this]() {
destroy();
disconnectFromServer();
returnToMainMenu();
}))->setPosition(0, -50, ABottomCenter)->setSize(300, 50);

// Start server button.
(new GuiButton(right_container, "START_SERVER", "Start scenario", [this]() {
(new GuiButton(right_container, "START_SERVER", tr("Start scenario"), [this]() {
startScenario();
}))->setPosition(0, -50, ABottomCenter)->setSize(300, 50);

Expand Down Expand Up @@ -221,11 +222,11 @@ void ServerCreationScreen::selectScenario(string filename)
scenario_description->setText("");

variation_selection->setSelectionIndex(0);
variation_names_list = {"None"};
variation_names_list = {tr("variation", "None")};
gameGlobalInfo->variation = variation_names_list[0];

variation_descriptions_list = {"No variation."};
variation_description->setText("No variation selected. Play the scenario as intended.");
variation_descriptions_list = {tr("No variation.")};
variation_description->setText(tr("No variation selected. Play the scenario as intended."));

// Open the scenario file.
ScenarioInfo info(selected_scenario_filename);
Expand Down

0 comments on commit 90fbe46

Please sign in to comment.