Beispiel #1
0
iwMainMenu::iwMainMenu(GameWorldView& gwv, GameCommandFactory& gcFactory)
    : IngameWindow(CGI_MAINSELECTION, IngameWindow::posLastOrCenter, 190, 286, _("Main selection"), LOADER.GetImageN("io", 5)),
      gwv(gwv), gcFactory(gcFactory)
{
    // Verteilung
    AddImageButton( 0,  12,  22,  53, 44, TC_GREY, LOADER.GetImageN("io", 134), _("Distribution of goods"));
    // Transport
    AddImageButton( 1,  68,  22,  53, 44, TC_GREY, LOADER.GetImageN("io", 198), _("Transport"));
    // Werkzeugproduktion
    AddImageButton( 2, 124,  22,  53, 44, TC_GREY, LOADER.GetImageN("io", 137), _("Tools"));

    // Statistiken
    AddImageButton( 3,  12,  70,  39, 44, TC_GREY, LOADER.GetImageN("io", 166), _("General statistics"));
    AddImageButton( 4,  54,  70,  39, 44, TC_GREY, LOADER.GetImageN("io", 135), _("Merchandise statistics"));
    AddImageButton( 5,  96,  70,  39, 44, TC_GREY, LOADER.GetImageN("io", 132), _("Buildings"));

    // Inventur
    AddImageButton( 6, 138,  70,  39, 44, TC_GREY, LOADER.GetImageN("io", 214), _("Stock"));

    // Gebäude
    AddImageButton( 7,  12, 118,  53, 44, TC_GREY, LOADER.GetImageN("io", 136), _("Productivity"));
    // Militär
    AddImageButton( 8,  68, 118,  53, 44, TC_GREY, LOADER.GetImageN("io", 133), _("Military"));
    // Schiffe
    AddImageButton( 9, 124, 118,  53, 44, TC_GREY, LOADER.GetImageN("io", 175), _("Ship register"));

    // Baureihenfolge
    if(gwv.GetWorld().GetGGS().isEnabled(AddonId::CUSTOM_BUILD_SEQUENCE))
        AddImageButton( 10,  12, 166,  53, 44, TC_GREY, LOADER.GetImageN("io", 24), _("Building sequence"));

    // Diplomatie (todo: besseres Bild suchen)
    AddImageButton( 11,  68, 166,  53, 44, TC_GREY, LOADER.GetImageN("io", 190), _("Diplomacy"));

    // AI-Debug
    if(gwv.GetViewer().GetPlayer().isHost && gwv.GetWorld().GetGGS().isEnabled(AddonId::AI_DEBUG_WINDOW))
        AddImageButton( 13,  80, 210,  20, 20, TC_GREY, NULL, _("AI Debug Window"));

    // Optionen
    AddImageButton(30,  12, 231, 165, 32, TC_GREY, LOADER.GetImageN("io",  37), _("Options"));
}
Beispiel #2
0
iwBuildings::iwBuildings(GameWorldView& gwv, GameCommandFactory& gcFactory):
    IngameWindow(CGI_BUILDINGS, IngameWindow::posAtMouse,  185, 480, _("Buildings"), LOADER.GetImageN("resource", 41)),
    gwv(gwv), gcFactory(gcFactory)
{
    const Nation playerNation = gwv.GetViewer().GetPlayer().nation;
    // Symbole für die einzelnen Gebäude erstellen
    for(unsigned short y = 0; y < BUILDINGS_COUNT / 4 + (BUILDINGS_COUNT % 4 > 0 ? 1 : 0); ++y)
    {
        for(unsigned short x = 0; x < ((y == BUILDINGS_COUNT / 4) ? BUILDINGS_COUNT % 4 : 4); ++x)
        {
			if(bts[y*4+x] != BLD_CHARBURNER)
            {
                AddImageButton(y * 4 + x, iconPadding.x - 16 + iconSpacing.x * x, iconPadding.y - 16 + iconSpacing.y * y, 32, 32, TC_GREY, LOADER.GetImageN(NATION_ICON_IDS[playerNation], bts[y * 4 + x]), _(BUILDING_NAMES[bts[y * 4 + x]]));
            }
			else
				AddImageButton(y * 4 + x, iconPadding.x - 16 + iconSpacing.x * x, iconPadding.y - 16  + iconSpacing.y * y,32,32,TC_GREY,LOADER.GetImageN("charburner", playerNation * 8 + 8) , _(BUILDING_NAMES[bts[y * 4 + x]]));
        }
    }

    // Hilfe-Button
    AddImageButton(32, width_ - 14 - 30, height_ - 20 - 32, 30, 32, TC_GREY, LOADER.GetImageN("io", 225), _("Help"));

}
Beispiel #3
0
iwAction::iwAction(GameInterface& gi, GameWorldView& gwv, const Tabs& tabs, MapPoint selectedPt, int mouse_x, int mouse_y, unsigned int params, bool military_buildings)
    : IngameWindow(CGI_ACTION, mouse_x, mouse_y, 200, 254, _("Activity window"), LOADER.GetImageN("io", 1)),
      gi(gi), gwv(gwv), selectedPt(selectedPt), mousePosAtOpen_(mouse_x, mouse_y)
{
    /*
        TAB_FLAG    1 = Land road
        TAB_FLAG    2 = Waterway
        TAB_FLAG    3 = Pull down flag
        TAB_FLAG    4 = Send geologist
        TAB_FLAG    5 = Send scout

        TAB_CUTROAD 1 = Cut Road

        TAB_BUILD   100-108, 200-212, 300-303, 400-403 = Buildings

        TAB_SETFLAG 1 = Erect flag

        TAB_WATCH   1 =
        TAB_WATCH   2 =
        TAB_WATCH   3 = zum HQ
		TAB_WATCH	4 = notify allies of location

        TAB_ATTACK  1 = Less soldiers
        TAB_ATTACK  2 = More soldiers
        TAB_ATTACK  3 = Option group: Better/Weaker
        TAB_ATTACK  4 = Angriff
        TAB_ATTACK  10-14 = Direktauswahl Anzahl
    */

    const GamePlayer& player = gwv.GetViewer().GetPlayer();

    /// Haupttab
    ctrlTab* main_tab = AddTabCtrl(0, 10, 20, 180);

    // Bau-main_tab
    if(tabs.build)
    {
        ctrlGroup* group =  main_tab->AddTab(LOADER.GetImageN("io", 18), _("-> Build house"), TAB_BUILD);

        ctrlTab* build_tab = group->AddTabCtrl(1, 0, 45, 180);

        // Building tabs
        if(tabs.build_tabs == Tabs::BT_MINE) //mines
            build_tab->AddTab(LOADER.GetImageN("io", 76), _("-> Dig mines"), Tabs::BT_MINE);
        else
        {
            build_tab->AddTab(LOADER.GetImageN("io", 67), _("-> Build hut"), Tabs::BT_HUT);
            if(tabs.build_tabs >= Tabs::BT_HOUSE)
                build_tab->AddTab(LOADER.GetImageN("io", 68), _("-> Build house"), Tabs::BT_HOUSE);
            if(tabs.build_tabs >= Tabs::BT_CASTLE) //castle & harbor
                build_tab->AddTab(LOADER.GetImageN("io", 69), _("-> Build castle"), Tabs::BT_CASTLE);
        }

        // add building icons to TabCtrl
        const unsigned char building_count_max = 14;
        const unsigned building_count[4] = { 9, 13, 6, 4 };
        const BuildingType building_icons[4][building_count_max] =
        {
            { /* 0 */
                /* 0 */ BLD_WOODCUTTER,
                /* 1 */ BLD_FORESTER,
                /* 2 */ BLD_QUARRY,
                /* 3 */ BLD_FISHERY,
                /* 4 */ BLD_HUNTER,
                /* 5 */ BLD_BARRACKS,
                /* 6 */ BLD_GUARDHOUSE,
                /* 7 */ BLD_LOOKOUTTOWER,
                /* 8 */ BLD_WELL
            },
            {/* 1 */
                /*  0 */ BLD_SAWMILL,
                /*  1 */ BLD_SLAUGHTERHOUSE,
                /*  2 */ BLD_MILL,
                /*  3 */ BLD_BAKERY,
                /*  4 */ BLD_IRONSMELTER,
                /*  5 */ BLD_METALWORKS,
                /*  6 */ BLD_ARMORY,
                /*  7 */ BLD_MINT,
                /*  8 */ BLD_SHIPYARD,
                /*  9 */ BLD_BREWERY,
                /* 10 */ BLD_STOREHOUSE,
                /* 11 */ BLD_WATCHTOWER,
                /* 12 */ BLD_CATAPULT
            },
            { /* 2 */
                /* 0 */ BLD_FARM,
                /* 1 */ BLD_PIGFARM,
                /* 2 */ BLD_DONKEYBREEDER,
                /* 3 */ BLD_CHARBURNER,
                /* 4 */ BLD_FORTRESS,
                /* 5 */ BLD_HARBORBUILDING
            },
            { /* 3 */
                /* 0 */ BLD_GOLDMINE,
                /* 1 */ BLD_IRONMINE,
                /* 2 */ BLD_COALMINE,
                /* 3 */ BLD_GRANITEMINE
            }
        };

        const unsigned TABS_COUNT[5] = {1, 2, 3, 1, 3};

        /// Flexible what-buildings-are-available handling
        bool building_available[4][building_count_max] ;

        // First enable all buildings
        for (unsigned char i = 0; i < 4; ++i)
        {
            for(unsigned char j = 0; j < building_count_max; ++j)
            {
                if (j < building_count[i])
                {
                    building_available[i][j] = player.IsBuildingEnabled(building_icons[i][j]);
                }
                else
                {
                    building_available[i][j] = false;
                }
            }
        }

        // Now deactivate those we don't want

        // Harbor
        if (tabs.build_tabs != Tabs::BT_HARBOR)
            building_available[2][5] = false;

        // Military buildings
        if (!military_buildings)
        {
            building_available[0][5] = false;
            building_available[0][6] = false;
            building_available[1][11] = false;
            building_available[2][4] = false;
        }

        // Mint and Goldmine
        if(gwv.GetWorld().GetGGS().isEnabled(AddonId::CHANGE_GOLD_DEPOSITS))
        {
            building_available[1][7] = false;
            building_available[3][0] = false;
        }

        // Catapult
        if (!player.CanBuildCatapult()) //-V807
            building_available[1][12] = false;

        // Charburner
        if(!gwv.GetWorld().GetGGS().isEnabled(AddonId::CHARBURNER))
            building_available[2][3] = false;

        for(unsigned char i = 0; i < TABS_COUNT[tabs.build_tabs]; ++i)
        {
            unsigned char k = 0;
            Tabs::BuildTab bt = (tabs.build_tabs == Tabs::BT_MINE) ? Tabs::BT_MINE : Tabs::BuildTab(i);

            for(unsigned char j = 0; j < building_count_max; ++j)
            {
                if (!building_available[bt][j])
                    continue;

                // Baukosten im Tooltip mit anzeigen
                std::stringstream tooltip;
                tooltip << _(BUILDING_NAMES[building_icons[bt][j]]);

                tooltip << _("\nCosts: ");
                if(BUILDING_COSTS[player.nation][building_icons[bt][j]].boards > 0)
                    tooltip << (int)BUILDING_COSTS[player.nation][building_icons[bt][j]].boards << _(" boards");
                if(BUILDING_COSTS[player.nation][building_icons[bt][j]].stones > 0)
                {
                    if(BUILDING_COSTS[player.nation][building_icons[bt][j]].boards > 0)
                        tooltip << ", ";
                    tooltip << (int)BUILDING_COSTS[player.nation][building_icons[bt][j]].stones << _(" stones");
                }

                build_tab->GetGroup(bt)->AddBuildingIcon(j, (k % 5) * 36, (k / 5) * 36 + 45, building_icons[bt][j], player.nation, 36, tooltip.str());

                ++k;
            }

            building_tab_heights[bt] = (k / 5 + ((k % 5 != 0) ? 1 : 0)) * 36 + 150;
        }

        build_tab->SetSelection(0, true);
    }

    // Wenn es einen Flaggen-main_tab gibt, dann entsprechend die Buttons anordnen, wie sie gebraucht werden
    if(tabs.flag)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 70), _("Erect flag"), TAB_FLAG);

        switch(params)
        {
            case AWFT_NORMAL: // normal Flag
            {
                group->AddImageButton(1,  0, 45, 45, 36, TC_GREY, LOADER.GetImageN("io",  65), _("Build road"));
                group->AddImageButton(3,  45, 45, 45, 36, TC_GREY, LOADER.GetImageN("io", 118), _("Pull down flag"));
                group->AddImageButton(4, 90, 45, 45, 36, TC_GREY, LOADER.GetImageN("io",  20), _("Call in geologist"));
                group->AddImageButton(5, 135, 45, 45, 36, TC_GREY, LOADER.GetImageN("io",  96), _("Send out scout"));
            } break;
            case AWFT_WATERFLAG: // Water flag
            {
                group->AddImageButton(1,  0, 45, 36, 36, TC_GREY, LOADER.GetImageN("io",  65), _("Build road"));
                group->AddImageButton(2,  36, 45, 36, 36, TC_GREY, LOADER.GetImageN("io",  95), _("Build waterway"));
                group->AddImageButton(3,  72, 45, 36, 36, TC_GREY, LOADER.GetImageN("io", 118), _("Pull down flag"));
                group->AddImageButton(4, 108, 45, 36, 36, TC_GREY, LOADER.GetImageN("io",  20), _("Call in geologist"));
                group->AddImageButton(5, 144, 45, 36, 36, TC_GREY, LOADER.GetImageN("io",  96), _("Send out scout"));
            } break;
            case AWFT_HQ: // HQ
            {
                group->AddImageButton(1, 0, 45, 180, 36, TC_GREY, LOADER.GetImageN("io", 65), _("Build road"));
            } break;
            case AWFT_STOREHOUSE: // Storehouse
            {
                group->AddImageButton(1, 0, 45, 90, 36, TC_GREY, LOADER.GetImageN("io", 65), _("Build road"));
                group->AddImageButton(3, 90, 45, 90, 36, TC_GREY, LOADER.GetImageN("io", 118), _("Demolish house"));
            } break;
        }
    }

    // Flagge Setzen-main_tab
    if(tabs.setflag)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 45), _("Erect flag"), TAB_SETFLAG);

        unsigned int nr = 70;
        if(params == AWFT_WATERFLAG)
            nr = 94;

        // Straße aufwerten ggf anzeigen
        unsigned int btWidth = 180, btPosX = 90;
        AddUpgradeRoad(group, btPosX, btWidth);

        group->AddImageButton(1, 0, 45, btWidth, 36, TC_GREY, LOADER.GetImageN("io", nr), _("Erect flag"));
    }

    // Cut-main_tab
    if(tabs.cutroad)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 19), _("Dig up road"), TAB_CUTROAD);

        // Straße aufwerten ggf anzeigen
        unsigned int btWidth = 180, btPosX = 0;
        if(!tabs.setflag)
            AddUpgradeRoad(group, btPosX, btWidth);

        group->AddImageButton(1, btPosX, 45, btWidth, 36, TC_GREY, LOADER.GetImageN("io", 32), _("Dig up road"));
    }

    if(tabs.attack)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 98), _("Attack options"), TAB_ATTACK);
        available_soldiers_count = params;
        AddAttackControls(group, params);
        selected_soldiers_count = 1;
    }

    if(tabs.sea_attack)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 177), _("Attack options"), TAB_SEAATTACK);

        selected_soldiers_count_sea = 1;
        available_soldiers_count_sea = gwv.GetViewer().GetNumSoldiersForSeaAttack(selectedPt);

        AddAttackControls(group, available_soldiers_count_sea);
    }

    // Beobachten-main_tab
    if(tabs.watch)
    {
        ctrlGroup* group = main_tab->AddTab(LOADER.GetImageN("io", 36), _("Display options"), TAB_WATCH);

        group->AddImageButton(1, 0, 45,  45, 36, TC_GREY, LOADER.GetImageN("io", 108), _("Observation window"));
        group->AddImageButton(2,  45, 45,  45, 36, TC_GREY, LOADER.GetImageN("io", 179), _("House names"));
        group->AddImageButton(3, 90, 45,  45, 36, TC_GREY, LOADER.GetImageN("io", 180), _("Go to headquarters"));
		group->AddImageButton(4, 135, 45,  45, 36, TC_GREY, LOADER.GetImageN("io", 107), _("Notify allies of this location"));
    }

    main_tab->SetSelection(0, true);

    if(x_ + GetWidth() > VIDEODRIVER.GetScreenWidth())
        x_ = mouse_x - GetWidth() - 40;
    if(y_ + GetHeight() > VIDEODRIVER.GetScreenHeight())
        y_ = mouse_y - GetHeight() - 40;

    VIDEODRIVER.SetMousePos(GetX() + 20, GetY() + 75);
}