private void CreateModCard(Mod mod, int currentRow, int currentCol) { PanelWidget modPreviewWidget = new PanelWidget("mod_panel_" + mod.name_id, 0, 0.3f, 0, 0, 2, 1, false); modPreviewWidget.ChangeRow(UI.ValueType.Percent, 100); modPreviewWidget.ChangeRow(UI.ValueType.Abosulte, 0.3f, 2); modPreviewWidget.Material = "SdkTrays/MiniTray"; browserMainPanel.ChangeRow(UI.ValueType.Abosulte, modPreviewWidget.Height, currentRow); browserMainPanel.AddWidget(currentRow, currentCol, modPreviewWidget, AlignMode.Center, AlignMode.Center, DockMode.Fill); PanelMaterialWidget pictureWidget = new PanelMaterialWidget("mod_pic_" + mod.name_id, "error.png"); modPreviewWidget.AddWidget(1, 1, pictureWidget, AlignMode.Center, AlignMode.Center, DockMode.Fill); PanelWidget modInfoWidget = new PanelWidget("mod_info_panel_" + mod.name_id, 0, 0, 0, 0, 1, 2, false); modInfoWidget.ChangeCol(UI.ValueType.Percent, 80); modInfoWidget.ChangeCol(UI.ValueType.Percent, 20, 2); modPreviewWidget.AddWidget(2, 1, modInfoWidget, AlignMode.Center, AlignMode.Center, DockMode.Fill); SimpleStaticTextWidget modNameWidget = new SimpleStaticTextWidget("mod_text_" + mod.name_id, mod.name, 0.2f, false, new Mogre.ColourValue()); modInfoWidget.AddWidget(1, 1, modNameWidget, AlignMode.Left, AlignMode.Center, DockMode.Fill, 1, 1, false); SimpleButtonWidget btnModSubscribeWidget = new SimpleButtonWidget("btnModSubscribeWidget_" + mod.name_id, "Subscribe", 0.8f, 0.7f); btnModSubscribeWidget.OnClick += (o) => { OnScreenEventChanged?.Invoke(btnModSubscribeWidget.Name, null); }; IBackendTask downloadModThumbTask = new DownloadBackendTask(mod.logo.original, "./Media/Engine/Download/" + mod.name_id + "_thumb.png"); BackendTaskManager.Instance.EnqueueTask(downloadModThumbTask); BackendTaskManager.Instance.TaskEnded += (o) => { pictureWidget.ChangeTexture(o.ToString()); }; modInfoWidget.AddWidget(1, 2, btnModSubscribeWidget, AlignMode.Center, AlignMode.Center); }
private void BtnFactions_OnClick(object sender) { ClearAllWidgets(); PanelWidget panelFactionList = UIManager.Instance.CreatePanel("panelFactionList", 0.3f, 0.92f, 0.7f, 0); panelFactionList.ChangeRow(UI.ValueType.Abosulte, 0.05f); panelFactionList.AddRow(UI.ValueType.Percent); panelFactionList.Padding.PaddingLeft = 0.01f; panelFactionList.Padding.PaddingRight = 0.01f; StaticText txtFactionsTitle = UIManager.Instance.CreateStaticText("txtFactionsTitle", GameString.FromString("ui_game_notes_factions_title", "Factions").ToString()); txtFactionsTitle.MetricMode = GuiMetricsMode.GMM_RELATIVE; panelFactionList.AddWidget(1, 1, txtFactionsTitle, AlignMode.Center); PanelScrollableWidget panelFactions = UIManager.Instance.CreateScrollablePanel("panelFactions", 1, 1, 0, 0, 1, 1, false); panelFactionList.AddWidget(2, 1, panelFactions, AlignMode.Center, AlignMode.Center, DockMode.Fill); panelFactions.ChangeRow(UI.ValueType.Abosulte, 0.03f); panelFactions.AddRows(world.ModData.SideInfos.Count - 1, UI.ValueType.Abosulte, 0.03f); int curRow = 1; widgets.Add(txtFactionsTitle); widgets.Add(panelFactionList); widgets.Add(panelFactions); foreach (var sideInfo in world.ModData.SideInfos) { if (!GameSlotManager.Instance.SlotEqual(sideInfo.ID, "slot_faction_state", "inactive") && !GameSlotManager.Instance.SlotEqual(sideInfo.ID, "slot_faction_visibility", "hidden")) { if (curRow == 1) { BuildFactionDetails(sideInfo); } var btnFaction = new SimpleStaticTextButton("txtFaction_" + sideInfo.Name, GameString.FromString(sideInfo.ID, sideInfo.Name).ToString(), (Color.FromArgb(36, 35, 191).ToColourValue()), ColourValue.Black, true); panelFactions.AddWidget(curRow, 1, btnFaction); btnFaction.UserData = sideInfo; btnFaction.OnClick += (evtObj) => { BuildFactionDetails((evtObj as Widget).UserData as ModSideDfnXML); }; curRow++; } } }
public override void Run() { var moddata = ScreenManager.Instance.ModData; chaData = moddata.CharacterInfos.Where(o => o.ID == chaID).FirstOrDefault(); if (chaData == null) { throw new Exception("Character Data can't be null!"); } var skinData = moddata.SkinInfos.Where(o => o.ID == chaData.Skin).FirstOrDefault(); if (skinData == null) { throw new Exception("Character Skin Data can't be null!"); } var idleSkinAnim = skinData[ChaAnimType.CAT_IDLE]; if (idleSkinAnim == null) { throw new Exception("Idle Skin Anim Data can't be null!"); } var idleAnim = moddata.AnimationInfos.Where(o => o.ID == idleSkinAnim.AnimID).FirstOrDefault(); if (idleAnim == null) { throw new Exception("Idle Anim Data can't be null!"); } discordPanel = UIManager.Instance.CreatePanel("discordPanel", 0.3f, 1); discordPanel.Padding.PaddingLeft = 0.01f; discordPanel.Padding.PaddingRight = 0.01f; discordPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); discordPanel.AddRow(UI.ValueType.Percent); var txtDiscord = UIManager.Instance.CreateStaticText("txtDiscord", "Discord"); txtDiscord.MetricMode = GuiMetricsMode.GMM_RELATIVE; discordInventoryPanel = UIManager.Instance.CreatePanel("discordInventoryPanel", 0.3f, 1, 0, 0, 9, 3); discordPanel.AddWidget(1, 1, txtDiscord, AlignMode.Center); discordPanel.AddWidget(2, 1, discordInventoryPanel, AlignMode.Center, AlignMode.Center, DockMode.Fill); int currRow = 1; int currCol = 1; for (int i = 0; i < 9; i++) { var invSlot = new PanelTemplateWidget("DiscordInvSlot_" + (i + 1).ToString(), "InventorySlot"); discordInventoryPanel.AddWidget(currRow, currCol, invSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); if ((i + 1) % 3 == 0) { currRow++; currCol = 1; } else { currCol++; } } playerPanel = UIManager.Instance.CreatePanel("playerPanel", 0.4f, 1, 0.3f); playerPanel.ChangeRow(UI.ValueType.Abosulte, 0.6f); playerPanel.AddRow(UI.ValueType.Abosulte, 0.4f); playerEquipPanel = UIManager.Instance.CreatePanel("playerEquipPanel", 1, 1); playerEquipPanel.Padding.PaddingLeft = 0.01f; playerEquipPanel.Padding.PaddingRight = 0.01f; playerPreviewPanel = UIManager.Instance.CreatePanel("playerPreviewPanel", 1, 1); playerPreviewPanel.Padding.PaddingLeft = 0.01f; playerPreviewPanel.Padding.PaddingRight = 0.01f; playerPreviewPanel.ChangeCol(UI.ValueType.Abosulte, 0.6f); playerPreviewPanel.AddCol(UI.ValueType.Abosulte, 0.4f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.1f); playerEquipPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddCol(UI.ValueType.Percent); playerEquipPanel.AddCol(UI.ValueType.Percent); playerPanel.AddWidget(1, 1, playerEquipPanel, AlignMode.Left, AlignMode.Center, DockMode.Fill); playerPanel.AddWidget(2, 1, playerPreviewPanel, AlignMode.Left, AlignMode.Center, DockMode.Fill); var txtOutfit = UIManager.Instance.CreateStaticText("txtOutfit", "Outfit"); var txtArms = UIManager.Instance.CreateStaticText("txtArms", "Arms"); txtOutfit.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtArms.MetricMode = GuiMetricsMode.GMM_RELATIVE; playerEquipPanel.AddWidget(1, 2, txtOutfit, AlignMode.Center); playerEquipPanel.AddWidget(1, 3, txtArms, AlignMode.Center); for (int i = 0; i < 9; i++) { var equipSlot = new PanelTemplateWidget("EquipSlot_" + (i + 1).ToString(), "InventorySlot"); switch (i) { case 0: playerEquipPanel.AddWidget(2, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 1: playerEquipPanel.AddWidget(3, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 2: playerEquipPanel.AddWidget(4, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 3: playerEquipPanel.AddWidget(5, 1, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 4: playerEquipPanel.AddWidget(2, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 5: playerEquipPanel.AddWidget(3, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 6: playerEquipPanel.AddWidget(4, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 7: playerEquipPanel.AddWidget(3, 1, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 8: playerEquipPanel.AddWidget(5, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; } } meshLayer = OverlayManager.Singleton.Create("CharacterPreview"); meshLayer.ZOrder = (ushort)(UIManager.Instance.GetCursorContainer().ZOrder - 1); gameObject = new Character(world, chaData, skinData, new Mogre.Vector3(), true); float length = gameObject.Mesh.Entity.BoundingBox.Size.Length * 2; gameObject.Mesh.Entity.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_MAX; gameObject.Mesh.EntityNode.Translate(new Mogre.Vector3(-2f, -6.3f, -1.0f * length)); gameObject.Mesh.EntityNode.Scale(0.7f, 0.8f, 0.8f); meshLayer.Add3D(gameObject.MeshNode); meshLayer.Show(); var txtPreviewHeadArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewHeadArmourTotal", "Head Armour Total: 0"); var txtPreviewBodyArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewBodyArmourTotal", "Body Armour Total: 0"); var txtPreviewLegArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewLegArmourTotal", "Leg Armour Total: 0"); var txtPreviewEncumbrance = UIManager.Instance.CreateStaticText("txtPreviewEncumbrance", "Encumbrance: 0"); txtPreviewHeadArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewBodyArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewLegArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewEncumbrance.MetricMode = GuiMetricsMode.GMM_RELATIVE; var btnReturn = UIManager.Instance.CreateButton("btnInventoryReturn", "Return", 200); btnReturn.MetricMode = GuiMetricsMode.GMM_RELATIVE; btnReturn.OnClick += (sender) => { ScreenManager.Instance.ChangeScreenReturn(); }; playerPreviewPanel.AddWidget(2, 2, txtPreviewHeadArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(3, 2, txtPreviewBodyArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(4, 2, txtPreviewLegArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(5, 2, txtPreviewEncumbrance, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(6, 2, btnReturn, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); backpackPanel = UIManager.Instance.CreatePanel("backpackPanel", 0.3f, 1, 0.7f, 0); backpackPanel.Padding.PaddingRight = 0.01f; backpackPanel.Padding.PaddingLeft = 0.01f; backpackPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); backpackPanel.AddRow(UI.ValueType.Percent); backpackPanel.AddRow(UI.ValueType.Abosulte, 0.03f); var txtInvTitle = UIManager.Instance.CreateStaticText("txtInvTitle", "Inventory"); txtInvTitle.MetricMode = GuiMetricsMode.GMM_RELATIVE; backpackInventoryPanel = UIManager.Instance.CreateScrollablePanel("backpackInventoryPanel", 1, 1, 0, 0, 20, 3); backpackPanel.AddWidget(1, 1, txtInvTitle, AlignMode.Center, AlignMode.Center, DockMode.Fill); backpackPanel.AddWidget(2, 1, backpackInventoryPanel, AlignMode.Center, AlignMode.Center, DockMode.Fill); int curRow = 1; int curCol = 1; for (int i = 0; i < 60; i++) { var invSlot = new PanelTemplateWidget("InvSlot_" + (i + 1).ToString(), "InventorySlot"); invSlot.Height = 0.1f; backpackInventoryPanel.ChangeRow(UI.ValueType.Abosulte, invSlot.Height, curRow); backpackInventoryPanel.AddWidget(curRow, curCol, invSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); if ((i + 1) % 3 == 0) { curRow++; curCol = 1; } else { curCol++; } } }