예제 #1
0
    private void BuildBuildMenu(SidebarState sidebar)
    {
        if (
            numBuildingOptions != sidebar.menu_items.Count ||
            SelectorChanged(sidebar.build_selector) ||
            mode != sidebar.mode
            )
        {
            ClearMenu();
            AddMenuButton("Cancel", CancelButton);

            numBuildingOptions = sidebar.menu_items.Count;
            for (int i = 0; i < sidebar.menu_items.Count; i++)
            {
                string index = i.ToString(); //They all end up with i being Count if we don't do this.
                var    item  = sidebar.menu_items[i];
                if (item.building_type != null)
                {
                    AddMenuButton(GameMap.buildings[item.building_type].name, delegate { BuildButton(index); });
                }
                else
                {
                    AddMenuButton(item.build_category.ToString(), delegate { BuildButton(index); });
                }
            }

            if (sidebar.build_selector != null)
            {
                AddHeader(GameMap.buildings[sidebar.build_selector.building_type].name);
                AddSpacer();
                foreach (var error in sidebar.build_selector.errors)
                {
                    AddError(error);
                }
                switch (sidebar.build_selector.stage)
                {
                case BuildSelectorStage.StageNoMat:
                    break;

                case BuildSelectorStage.StagePlace:
                    break;

                case BuildSelectorStage.StageItemSelect:
                    for (int i = 0; i < sidebar.build_selector.choices.Count; i++)
                    {
                        var    choice = sidebar.build_selector.choices[i];
                        string index  = i.ToString();    //They all end up with i being Count if we don't do this.
                        AddItemButton(choice.name, choice.distance.ToString(), choice.used_count + "/" + choice.num_candidates, delegate { BuildButton(index); });
                    }
                    break;

                default:
                    break;
                }
            }
        }
        mode = sidebar.mode;
    }
        void SetItemContextMenu(object sender, MouseEventArgs e)
        {
            ExitRenameMode();
            if (e.Button == MouseButtons.Right)
            {
                int index = Tabs.IndexOf(ActiveTab);

                if (index > 0)
                {
                    internalState |= SidebarState.CanMoveUp;
                }
                else
                {
                    internalState = internalState & ~SidebarState.CanMoveUp;
                }

                if (index < Tabs.Count - 1)
                {
                    internalState |= SidebarState.CanMoveDown;
                }
                else
                {
                    internalState = internalState & ~(SidebarState.CanMoveDown);
                }

                Tabs.DragOverTab = ActiveTab;
                Refresh();
                Tabs.DragOverTab = null;
            }

            if (e.Button == MouseButtons.Right)
            {
                // set moveup/down states correctly
                SetDeletedState(ActiveTab.SelectedItem);
                SetRenameState(ActiveTab.SelectedItem);

                int index = ActiveTab.Items.IndexOf(ActiveTab.SelectedItem);
                if (index > 0)
                {
                    internalState |= SidebarState.CanMoveItemUp;
                }
                else
                {
                    internalState = internalState & ~(SidebarState.CanMoveItemUp);
                }

                if (index < ActiveTab.Items.Count - 1)
                {
                    internalState |= SidebarState.CanMoveItemDown;
                }
                else
                {
                    internalState = internalState & ~(SidebarState.CanMoveItemDown);
                }

                MenuService.ShowContextMenu(this, sideTabContextMenuPath, sideTabContent, e.X, e.Y);
            }
        }
 void SetDeletedState(bool canBeDeleted)
 {
     if (canBeDeleted)
     {
         internalState |= SidebarState.TabCanBeDeleted;
     }
     else
     {
         internalState = internalState & ~SidebarState.TabCanBeDeleted;
     }
 }
 void SetRenameState(bool canBeRenamed)
 {
     if (canBeRenamed)
     {
         internalState |= SidebarState.CanBeRenamed;
     }
     else
     {
         internalState = internalState & ~SidebarState.CanBeRenamed;
     }
 }
        void SetContextMenu(object sender, MouseEventArgs e)
        {
            ExitRenameMode();

            int index = GetTabIndexAt(e.X, e.Y);

            if (index >= 0)
            {
                SideTab tab = Tabs[index];

                SetDeletedState(tab.CanBeDeleted);
                SetRenameState(tab.CanBeRenamed);

                if (index > 0)
                {
                    internalState |= SidebarState.CanMoveUp;
                }
                else
                {
                    internalState = internalState & ~SidebarState.CanMoveUp;
                }

                if (index < Tabs.Count - 1)
                {
                    internalState |= SidebarState.CanMoveDown;
                }
                else
                {
                    internalState = internalState & ~(SidebarState.CanMoveDown);
                }
                Tabs.DragOverTab = tab;
                Refresh();
                Tabs.DragOverTab = null;
            }

            if (e.Button == MouseButtons.Right)
            {
                MenuService.ShowContextMenu(this, contextMenuPath, this, e.X, e.Y);
            }
        }
예제 #6
0
 private void BuildDefaultMenu(SidebarState sidebar, bool force = false)
 {
     if (mode == ui_sidebar_mode.Default && !force)
     {
         return;
     }
     ClearMenu();
     AddMenuButton("View Announcements");
     AddMenuButton("Building", delegate { SetSidebar(ui_sidebar_mode.Build.ToString()); });
     AddMenuButton("Reports");
     AddMenuButton("Civilizations/World Info");
     AddMenuButton("Designations", delegate { SetSidebar(ui_sidebar_mode.DesignateMine.ToString()); });
     AddMenuButton("Set Order", delegate { SetSidebar(ui_sidebar_mode.Orders.ToString()); });
     AddMenuButton("Unit List");
     AddMenuButton("Lob List");
     AddMenuButton("Military");
     AddMenuButton("Squads", delegate { SetSidebar(ui_sidebar_mode.Squads.ToString()); });
     AddMenuButton("Points/Routes/Notes", delegate { SetSidebar(ui_sidebar_mode.NotesPoints.ToString()); });
     AddMenuButton("Make Burrows", delegate { SetSidebar(ui_sidebar_mode.Burrows.ToString()); });
     AddMenuButton("Hauling", delegate { SetSidebar(ui_sidebar_mode.Hauling.ToString()); });
     AddMenuButton("Stockpiles", delegate { SetSidebar(ui_sidebar_mode.Stockpiles.ToString()); });
     AddMenuButton("Zones", delegate { SetSidebar(ui_sidebar_mode.Zones.ToString()); });
     AddMenuButton("Set Building Tasks/Prefs", delegate { SetSidebar(ui_sidebar_mode.QueryBuilding.ToString()); });
     AddMenuButton("View Rooms/Buildings");
     AddMenuButton("View Items in Buildings", delegate { SetSidebar(ui_sidebar_mode.BuildingItems.ToString()); });
     AddMenuButton("View Units", delegate { SetSidebar(ui_sidebar_mode.ViewUnits.ToString()); });
     AddMenuButton("Hot Keys", delegate { SetSidebar(ui_sidebar_mode.Hotkeys.ToString()); });
     AddMenuButton("Locations and Occupations");
     AddMenuButton("Nobles and Administrators");
     AddMenuButton("Status");
     AddMenuButton("Look", delegate { SetSidebar(ui_sidebar_mode.LookAround.ToString()); });
     AddMenuButton("Help");
     AddMenuButton("Options");
     AddMenuButton("Depot Access", delegate { SetSidebar(ui_sidebar_mode.DepotAccess.ToString()); });
     pauseManager.playButton = AddMenuButton("Resume", TogglePause).gameObject;
     mode = ui_sidebar_mode.Default;
 }
예제 #7
0
		void SetDeletedState(bool canBeDeleted)
		{
			if (canBeDeleted) {
				internalState |= SidebarState.TabCanBeDeleted;
			} else {
				internalState = internalState & ~SidebarState.TabCanBeDeleted;
			}
		}
예제 #8
0
		void SetItemContextMenu(object sender, MouseEventArgs e)
		{
			ExitRenameMode();
			if (e.Button == MouseButtons.Right) {
				int index = Tabs.IndexOf(ActiveTab);
				
				if (index > 0) {
					internalState |= SidebarState.CanMoveUp;
				} else {
					internalState = internalState & ~SidebarState.CanMoveUp;
				}
				
				if (index < Tabs.Count - 1) {
					internalState |= SidebarState.CanMoveDown;
				} else {
					internalState = internalState & ~(SidebarState.CanMoveDown);
				}
				
				Tabs.DragOverTab = ActiveTab;
				Refresh();
				Tabs.DragOverTab = null;
			}
			
			if (e.Button == MouseButtons.Right) {
				// set moveup/down states correctly
				SetDeletedState(ActiveTab.SelectedItem);
				SetRenameState(ActiveTab.SelectedItem);
				
				int index = ActiveTab.Items.IndexOf(ActiveTab.SelectedItem);
				if (index > 0) {
					internalState |= SidebarState.CanMoveItemUp;
				} else {
					internalState = internalState & ~(SidebarState.CanMoveItemUp);
				}
				
				if (index < ActiveTab.Items.Count - 1) {
					internalState |= SidebarState.CanMoveItemDown;
				} else {
					internalState = internalState & ~(SidebarState.CanMoveItemDown);
				}
				
				SD.WinForms.MenuService.ShowContextMenu(this, sideTabContextMenuPath, sideTabContent, e.X, e.Y);
			}
		}
예제 #9
0
		void SetContextMenu(object sender, MouseEventArgs e)
		{
			ExitRenameMode();
			
			int index = GetTabIndexAt(e.X, e.Y);
			if (index >= 0) {
				SideTab tab = Tabs[index];
				
				SetDeletedState(tab.CanBeDeleted);
				SetRenameState(tab.CanBeRenamed);
				
				if (index > 0) {
					internalState |= SidebarState.CanMoveUp;
				} else {
					internalState = internalState & ~SidebarState.CanMoveUp;
				}
				
				if (index < Tabs.Count - 1) {
					internalState |= SidebarState.CanMoveDown;
				} else {
					internalState = internalState & ~(SidebarState.CanMoveDown);
				}
				Tabs.DragOverTab = tab;
				Refresh();
				Tabs.DragOverTab = null;
			}
			
			if (e.Button == MouseButtons.Right) {
				SD.WinForms.MenuService.ShowContextMenu(this, contextMenuPath, this, e.X, e.Y);
			}
		}
예제 #10
0
		void SetRenameState(bool canBeRenamed)
		{
			if (canBeRenamed) {
				internalState |= SidebarState.CanBeRenamed;
			} else {
				internalState = internalState & ~SidebarState.CanBeRenamed;
			}
		}
예제 #11
0
    private void BuildDigMenu(SidebarState sidebar)
    {
        switch (sidebar.mode)
        {
        case ui_sidebar_mode.DesignateMine:
            diggingTool.digMode = DiggingTool.DigMode.Dig;
            break;

        case ui_sidebar_mode.DesignateRemoveRamps:
            diggingTool.digMode = DiggingTool.DigMode.RemoveUpStairRamp;
            break;

        case ui_sidebar_mode.DesignateUpStair:
            diggingTool.digMode = DiggingTool.DigMode.UpStair;
            break;

        case ui_sidebar_mode.DesignateDownStair:
            diggingTool.digMode = DiggingTool.DigMode.DownStair;
            break;

        case ui_sidebar_mode.DesignateUpDownStair:
            diggingTool.digMode = DiggingTool.DigMode.UpDownStair;
            break;

        case ui_sidebar_mode.DesignateUpRamp:
            diggingTool.digMode = DiggingTool.DigMode.UpRamp;
            break;

        case ui_sidebar_mode.DesignateChannel:
            diggingTool.digMode = DiggingTool.DigMode.Channel;
            break;

        case ui_sidebar_mode.DesignateGatherPlants:
            diggingTool.digMode = DiggingTool.DigMode.GatherPlants;
            break;

        case ui_sidebar_mode.DesignateRemoveDesignation:
            diggingTool.digMode = DiggingTool.DigMode.RemoveDesignation;
            break;

        case ui_sidebar_mode.DesignateSmooth:
            diggingTool.digMode = DiggingTool.DigMode.SmoothStone;
            break;

        case ui_sidebar_mode.DesignateCarveTrack:
            break;

        case ui_sidebar_mode.DesignateEngrave:
            diggingTool.digMode = DiggingTool.DigMode.EngraveStone;
            break;

        case ui_sidebar_mode.DesignateCarveFortification:
            diggingTool.digMode = DiggingTool.DigMode.CarveFortifications;
            break;
        }

        if (sidebar.mode == mode)
        {
            return;
        }
        mode = sidebar.mode;
        ClearMenu();
        AddMenuButton("Cancel", CancelButton);
        AddMenuButton("Mine", delegate { SetSidebar(ui_sidebar_mode.DesignateMine.ToString()); });
        AddMenuButton("Channel", delegate { SetSidebar(ui_sidebar_mode.DesignateChannel.ToString()); });
        AddMenuButton("Up Stair", delegate { SetSidebar(ui_sidebar_mode.DesignateUpStair.ToString()); });
        AddMenuButton("Down Stair", delegate { SetSidebar(ui_sidebar_mode.DesignateDownStair.ToString()); });
        AddMenuButton("U/D Stair", delegate { SetSidebar(ui_sidebar_mode.DesignateUpDownStair.ToString()); });
        AddMenuButton("Up Ramp", delegate { SetSidebar(ui_sidebar_mode.DesignateUpRamp.ToString()); });
        AddMenuButton("Remove Up Stairs/Ramps", delegate { SetSidebar(ui_sidebar_mode.DesignateRemoveRamps.ToString()); });
        AddMenuButton("Chop Down Trees", delegate { SetSidebar(ui_sidebar_mode.DesignateChopTrees.ToString()); });
        AddMenuButton("Gather Plants", delegate { SetSidebar(ui_sidebar_mode.DesignateGatherPlants.ToString()); });
        AddMenuButton("Smooth Stone", delegate { SetSidebar(ui_sidebar_mode.DesignateSmooth.ToString()); });
        AddMenuButton("Engrave Stone", delegate { SetSidebar(ui_sidebar_mode.DesignateEngrave.ToString()); });
        AddMenuButton("Carve Fortifications", delegate { SetSidebar(ui_sidebar_mode.DesignateCarveFortification.ToString()); });
        AddMenuButton("Carve Track", delegate { SetSidebar(ui_sidebar_mode.DesignateCarveTrack.ToString()); });
        AddMenuButton("Toggle Engravings", delegate { SetSidebar(ui_sidebar_mode.DesignateToggleEngravings.ToString()); });
        AddMenuButton("Toggle Standard/Marking", delegate { SetSidebar(ui_sidebar_mode.DesignateToggleMarker.ToString()); });
        AddMenuButton("Remove Construction", delegate { SetSidebar(ui_sidebar_mode.DesignateRemoveConstruction.ToString()); });
        AddMenuButton("Remove Designation", delegate { SetSidebar(ui_sidebar_mode.DesignateRemoveDesignation.ToString()); });
        AddMenuButton("Set Building/Item Properties", delegate { SetSidebar(ui_sidebar_mode.DesignateItemsClaim.ToString()); });
        AddMenuButton("Set Traffic Areas", delegate { SetSidebar(ui_sidebar_mode.DesignateTrafficNormal.ToString()); });
    }
예제 #12
0
    void UpdateMenu(SidebarState sidebar)
    {
        switch (sidebar.mode)
        {
        case ui_sidebar_mode.Default:
            BuildDefaultMenu(sidebar);
            break;

        case ui_sidebar_mode.Build:
            BuildBuildMenu(sidebar);
            break;

        case ui_sidebar_mode.DesignateMine:
        case ui_sidebar_mode.DesignateRemoveRamps:
        case ui_sidebar_mode.DesignateUpStair:
        case ui_sidebar_mode.DesignateDownStair:
        case ui_sidebar_mode.DesignateUpDownStair:
        case ui_sidebar_mode.DesignateUpRamp:
        case ui_sidebar_mode.DesignateChannel:
        case ui_sidebar_mode.DesignateGatherPlants:
        case ui_sidebar_mode.DesignateRemoveDesignation:
        case ui_sidebar_mode.DesignateSmooth:
        case ui_sidebar_mode.DesignateCarveTrack:
        case ui_sidebar_mode.DesignateEngrave:
        case ui_sidebar_mode.DesignateCarveFortification:
            BuildDigMenu(sidebar);
            break;

        case ui_sidebar_mode.Squads:
        case ui_sidebar_mode.Stockpiles:
        case ui_sidebar_mode.QueryBuilding:
        case ui_sidebar_mode.Orders:
        case ui_sidebar_mode.OrdersForbid:
        case ui_sidebar_mode.OrdersRefuse:
        case ui_sidebar_mode.OrdersWorkshop:
        case ui_sidebar_mode.OrdersZone:
        case ui_sidebar_mode.BuildingItems:
        case ui_sidebar_mode.ViewUnits:
        case ui_sidebar_mode.LookAround:
        case ui_sidebar_mode.DesignateItemsClaim:
        case ui_sidebar_mode.DesignateItemsForbid:
        case ui_sidebar_mode.DesignateItemsMelt:
        case ui_sidebar_mode.DesignateItemsUnmelt:
        case ui_sidebar_mode.DesignateItemsDump:
        case ui_sidebar_mode.DesignateItemsUndump:
        case ui_sidebar_mode.DesignateItemsHide:
        case ui_sidebar_mode.DesignateItemsUnhide:
        case ui_sidebar_mode.DesignateChopTrees:
        case ui_sidebar_mode.DesignateToggleEngravings:
        case ui_sidebar_mode.DesignateToggleMarker:
        case ui_sidebar_mode.Hotkeys:
        case ui_sidebar_mode.DesignateTrafficHigh:
        case ui_sidebar_mode.DesignateTrafficNormal:
        case ui_sidebar_mode.DesignateTrafficLow:
        case ui_sidebar_mode.DesignateTrafficRestricted:
        case ui_sidebar_mode.Zones:
        case ui_sidebar_mode.ZonesPenInfo:
        case ui_sidebar_mode.ZonesPitInfo:
        case ui_sidebar_mode.ZonesHospitalInfo:
        case ui_sidebar_mode.ZonesGatherInfo:
        case ui_sidebar_mode.DesignateRemoveConstruction:
        case ui_sidebar_mode.DepotAccess:
        case ui_sidebar_mode.NotesPoints:
        case ui_sidebar_mode.NotesRoutes:
        case ui_sidebar_mode.Burrows:
        case ui_sidebar_mode.Hauling:
        case ui_sidebar_mode.ArenaWeather:
        case ui_sidebar_mode.ArenaTrees:
        default:
            if (mode != sidebar.mode)
            {
                ClearMenu();
                AddMenuButton("Cancel", CancelButton);
                mode = sidebar.mode;
            }
            break;
        }
    }