示例#1
0
/**
 *  Konstruktor von @p dskSelectMap.
 *
 *  @param[in] type Typ des Servers
 *  @param[in] name Server-Name
 *  @param[in] pass Server-Passwort
 */
dskSelectMap::dskSelectMap(const CreateServerInfo& csi)
    : Desktop(LOADER.GetImageN("setup015", 0)),
      csi(csi)
{
    // Die Tabelle für die Maps
    AddTable( 1, 110,  35, 680, 400, TC_GREY, NormalFont, 6, _("Name"), 250, ctrlTable::SRT_STRING, _("Author"), 216, ctrlTable::SRT_STRING, _("Player"), 170, ctrlTable::SRT_NUMBER, _("Type"), 180, ctrlTable::SRT_STRING, _("Size"), 134, ctrlTable::SRT_MAPSIZE, "", 0, ctrlTable::SRT_STRING);

    // "Karten Auswahl"
    AddText(  2, 400,   5, _("Selection of maps"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, LargeFont);

    // "Zurück"
    AddTextButton(3, 380, 560, 200, 22, TC_RED1, _("Back"), NormalFont);
    // "Spiel laden..."
    AddTextButton(4, 590, 530, 200, 22, TC_GREEN2, _("Load game..."), NormalFont);
    // "Weiter"
    AddTextButton(5, 590, 560, 200, 22, TC_GREEN2, _("Continue"), NormalFont);

    ctrlOptionGroup* optiongroup = AddOptionGroup(10, ctrlOptionGroup::CHECK, scale_);
    // "Alte"
    optiongroup->AddTextButton(0, 10,  35, 90,  22, TC_GREY, _("Old maps"), NormalFont);
    // "Neue"
    optiongroup->AddTextButton(1, 10,  60, 90,  22, TC_GREY, _("New maps"), NormalFont);
    // "Eigene"
    optiongroup->AddTextButton(2, 10,  85, 90,  22, TC_GREY, _("Own maps"), NormalFont);
    // "Kontinente"
    optiongroup->AddTextButton(3, 10, 110, 90,  22, TC_GREY, _("Continents"), NormalFont);
    // "Kampagne"
    optiongroup->AddTextButton(4, 10, 135, 90,  22, TC_GREY, _("Campaign"), NormalFont);
    // "RTTR"
    optiongroup->AddTextButton(5, 10, 160, 90,  22, TC_GREY, _("RTTR"), NormalFont);
    // "Andere"
    optiongroup->AddTextButton(6, 10, 185, 90,  22, TC_GREY, _("Other"), NormalFont);
    // "Andere"
    optiongroup->AddTextButton(7, 10, 210, 90,  22, TC_GREY, _("Sea"), NormalFont);
    // "Heruntergeladene"
    optiongroup->AddTextButton(8, 10, 235, 90,  22, TC_GREY, _("Played"), NormalFont);

    AddPreviewMinimap(11, 110, 445, 140, 140, NULL);
    AddText(12, 260, 470, _("Map: "), COLOR_YELLOW, glArchivItem_Font::DF_LEFT, NormalFont);
    AddText(13, 260, 490, _("Mapfile: "), COLOR_YELLOW, glArchivItem_Font::DF_LEFT, NormalFont);

    // "Eigene" auswählen
    optiongroup->SetSelection(5, true);

    LOBBYCLIENT.SetInterface(this);
    GAMECLIENT.SetInterface(this);
}
示例#2
0
dskHostGame::dskHostGame(const ServerType serverType) :
    Desktop(LOADER.GetImageN("setup015", 0)), hasCountdown_(false), serverType(serverType), wasActivated(false)
{
    if(!GAMECLIENT.GetLuaFilePath().empty())
    {
        lua.reset(new LuaInterfaceSettings());
        if(!lua->LoadScript(GAMECLIENT.GetLuaFilePath()))
        {
            WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("Lua script was found but failed to load. Map might not work as expected!"), this, MSB_OK, MSB_EXCLAMATIONRED, 1));
            lua.reset();
        } else if(!lua->EventSettingsInit(serverType == ServerType::LOCAL, GAMECLIENT.IsSavegame()))
        {
            RTTR_Assert(GAMECLIENT.IsHost()); // This should be done first for the host so others won't even see the script
            LOG.lprintf("Lua was disabled by the script itself\n");
            lua.reset();
            // Double check...
            if(GAMECLIENT.IsHost())
                GAMESERVER.RemoveLuaScript();
        }
    }


    const bool readonlySettings = !GAMECLIENT.IsHost() || GAMECLIENT.IsSavegame() || (lua && !lua->IsChangeAllowed("general"));
    allowAddonChange = GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame() && (!lua || lua->IsChangeAllowed("addonsAll") || lua->IsChangeAllowed("addonsSome"));

    // Kartenname
    AddText(0, 400, 5, GAMECLIENT.GetGameName(), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, LargeFont);

    // "Spielername"
    AddText(10, 95, 40, _("Player Name"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    // "Einstufung"
    AddText(11, 205, 40, _("Classification"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    // "Volk"
    AddText(12, 285, 40, _("Race"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    // "Farbe"
    AddText(13, 355, 40, _("Color"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    // "Team"
    AddText(14, 405, 40, _("Team"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);

    if (!IsSinglePlayer())
    {
        // "Bereit"
        AddText(15, 465, 40, _("Ready?"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
        // "Ping"
        AddText(16, 515, 40, _("Ping"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    }
    // "Swap"
    if(GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame())
        AddText(24, 10, 40, _("Swap"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
    // "Verschieben" (nur bei Savegames!)
    if(GAMECLIENT.IsSavegame())
        AddText(17, 645, 40, _("Past player"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);

    if (!IsSinglePlayer())
    {
        // Chatfenster
        AddChatCtrl(1, 20, 320, 360, 218, TC_GREY, NormalFont);
        // Edit für Chatfenster
        AddEdit(4, 20, 540, 360, 22, TC_GREY, NormalFont);
    }

    // "Spiel starten"
    AddTextButton(2, 600, 560, 180, 22, TC_GREEN2, (GAMECLIENT.IsHost() ? _("Start game") : _("Ready")), NormalFont);

    // "Zurück"
    AddTextButton(3, 400, 560, 180, 22, TC_RED1, _("Return"), NormalFont);

    // "Teams sperren"
    AddCheckBox(20, 400, 460, 180, 26, TC_GREY, _("Lock teams:"), NormalFont, readonlySettings);
    // "Gemeinsame Team-Sicht"
    AddCheckBox(19, 600, 460, 180, 26, TC_GREY, _("Shared team view"), NormalFont, readonlySettings);
    // "Random Start Locations"
    AddCheckBox(23, 600, 430, 180, 26, TC_GREY, _("Random start locations"), NormalFont, readonlySettings);

    // "Enhancements"
    AddText(21, 400, 499, _("Addons:"), COLOR_YELLOW, 0, NormalFont);
    AddTextButton(22, 600, 495, 180, 22, TC_GREEN2, allowAddonChange ? _("Change Settings...") : _("View Settings..."), NormalFont);

    ctrlComboBox* combo;

    // umgedrehte Reihenfolge, damit die Listen nicht dahinter sind

    // "Aufklärung"
    AddText(30, 400, 405, _("Exploration:"), COLOR_YELLOW, 0, NormalFont);
    combo = AddComboBox(40, 600, 400, 180, 20, TC_GREY, NormalFont, 100, readonlySettings);
    combo->AddString(_("Off (all visible)"));
    combo->AddString(_("Classic (Settlers 2)"));
    combo->AddString(_("Fog of War"));
    combo->AddString(_("FoW - all explored"));

    // "Waren zu Beginn"
    AddText(31, 400, 375, _("Goods at start:"), COLOR_YELLOW, 0, NormalFont);
    combo = AddComboBox(41, 600, 370, 180, 20, TC_GREY, NormalFont, 100, readonlySettings);
    combo->AddString(_("Very Low"));
    combo->AddString(_("Low"));
    combo->AddString(_("Normal"));
    combo->AddString(_("A lot"));

    // "Spielziel"
    AddText(32, 400, 345, _("Goals:"), COLOR_YELLOW, 0, NormalFont);
    combo = AddComboBox(42, 600, 340, 180, 20, TC_GREY, NormalFont, 100, readonlySettings);
    combo->AddString(_("None")); // Kein Spielziel
    combo->AddString(_("Conquer 3/4 of map")); // Besitz 3/4 des Landes
    combo->AddString(_("Total domination")); // Alleinherrschaft
    // Lobby game?
    if(LOBBYCLIENT.LoggedIn())
    {
        // Then add tournament modes as possible "objectives"
        for(unsigned i = 0; i < TOURNAMENT_MODES_COUNT; ++i)
        {
            char str[512];
            sprintf (str, _("Tournament: %u minutes"), TOURNAMENT_MODES_DURATION[i]);
            combo->AddString(str);
        }
    }

    // "Geschwindigkeit"
    AddText(33, 400, 315, _("Speed:"), COLOR_YELLOW, 0, NormalFont);
    combo = AddComboBox(43, 600, 310, 180, 20, TC_GREY, NormalFont, 100, !GAMECLIENT.IsHost());
    combo->AddString(_("Very slow")); // Sehr Langsam
    combo->AddString(_("Slow")); // Langsam
    combo->AddString(_("Normal")); // Normal
    combo->AddString(_("Fast")); // Schnell
    combo->AddString(_("Very fast")); // Sehr Schnell

    // Karte laden, um Kartenvorschau anzuzeigen
    if(GAMECLIENT.GetMapType() == MAPTYPE_OLDMAP)
    {
        // Map laden
        libsiedler2::ArchivInfo mapArchiv;
        // Karteninformationen laden
        if(libsiedler2::loader::LoadMAP(GAMECLIENT.GetMapPath(), mapArchiv) == 0)
        {
            glArchivItem_Map* map = static_cast<glArchivItem_Map*>(mapArchiv.get(0));
            ctrlPreviewMinimap* preview = AddPreviewMinimap(70, 560, 40, 220, 220, map);

            // Titel der Karte, Y-Position relativ je nach Höhe der Minimap festlegen, daher nochmals danach
            // verschieben, da diese Position sonst skaliert wird!
            ctrlText* text = AddText(71, 670, 0, _("Map: ") +  GAMECLIENT.GetMapTitle(), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont);
            text->Move(text->GetX(false), preview->GetY(false) + preview->GetBottom() + 10);
        }
    }

    if (IsSinglePlayer() && !GAMECLIENT.IsSavegame())
    {
        // Setze initial auf KI
        for (unsigned char i = 0; i < GAMECLIENT.GetPlayerCount(); i++)
        {
            if (!GAMECLIENT.GetPlayer(i).is_host)
                GAMESERVER.TogglePlayerState(i);
        }
    }

    // Alle Spielercontrols erstellen
    for(unsigned char i = GAMECLIENT.GetPlayerCount(); i; --i)
        UpdatePlayerRow(i - 1);
    //swap buttons erstellen
    if(GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame() && (!lua || lua->IsChangeAllowed("swapping")))
    {
        for(unsigned char i = GAMECLIENT.GetPlayerCount(); i; --i)
            AddTextButton(80 + i, 5, 80 + (i - 1) * 30, 10, 22, TC_RED1, _("-"), NormalFont);;
    }
    // GGS aktualisieren, zum ersten Mal
    GAMECLIENT.LoadGGS();
    this->CI_GGSChanged(GAMECLIENT.GetGGS());

    LOBBYCLIENT.SetInterface(this);
    if(serverType == ServerType::LOBBY && LOBBYCLIENT.LoggedIn())
    {
        LOBBYCLIENT.SendServerJoinRequest();
        LOBBYCLIENT.SendRankingInfoRequest(GAMECLIENT.GetPlayer(GAMECLIENT.GetPlayerID()).name);
        for(unsigned char i = 0; i < GAMECLIENT.GetPlayerCount(); ++i)
        {
            GameClientPlayer& player = GAMECLIENT.GetPlayer(i);
            if(player.ps == PS_OCCUPIED)
                LOBBYCLIENT.SendRankingInfoRequest(player.name);
        }
    }

    GAMECLIENT.SetInterface(this);
}