private void SetupGui() { // Stolen from base implementation var mainBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0.0, 100.0); var bkgrBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); var listBounds = ElementBounds.Fixed(GuiStyle.ElementToDialogPadding - 2.0, 50.0, 500.0, 580); var clipBounds = listBounds.ForkBoundingParent(); var sideBounds = listBounds.FlatCopy().FixedGrow(6.0).WithFixedOffset(-3.0, -3.0); var scrlBounds = sideBounds.CopyOffsetedSibling(3.0 + listBounds.fixedWidth + 7.0).WithFixedWidth(20.0); var quitBounds = ElementBounds.FixedSize(0.0, 0.0).FixedUnder(clipBounds, 18.0).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(20.0, 4.0).WithFixedAlignmentOffset(2.0, 0.0); bkgrBounds.BothSizing = ElementSizing.FitToChildren; bkgrBounds.WithChildren(sideBounds, listBounds, scrlBounds, quitBounds); // Compose the window mainWindow = capi.Gui.CreateCompo("svgTest", mainBounds) .AddShadedDialogBG(bkgrBounds) .AddDialogTitleBar("SVG Sample", OnTitleBarClose) .BeginChildElements(bkgrBounds) .BeginClip(clipBounds) .AddInset(sideBounds, 3) .AddHandbookStackList(listBounds, OnLeftClickListElement, listItems, "stackList") .EndClip() .AddVerticalScrollbar(OnNewScrollbarValueOverviewPage, scrlBounds, "scrollbar") .AddSmallButton(Lang.Get("general-close"), TryClose, quitBounds) .EndChildElements() .Compose(); mainWindow.GetScrollbar("scrollbar") .SetHeights(580, (float)mainWindow.GetHandbookStackList("stackList").insideBounds.fixedHeight); }
private void onCmdMapSize(int groupId, CmdArgs args) { mapWidth = (int)args.PopInt(1200); mapHeight = (int)args.PopInt(800); fullDialog = ComposeDialog(EnumDialogType.Dialog); capi.ShowChatMessage(string.Format("Map size {0}x{1} set", mapWidth, mapHeight)); }
public GuiDialogWorldMap(OnViewChangedDelegate viewChanged, ICoreClientAPI capi) : base("", capi) { this.viewChanged = viewChanged; fullDialog = ComposeDialog(EnumDialogType.Dialog); hudDialog = ComposeDialog(EnumDialogType.HUD); capi.RegisterCommand("worldmapsize", "Set the size of the world map dialog", "width height", onCmdMapSize); }
public static GuiComposer AddFlatList(this GuiComposer composer, ElementBounds bounds, Action <int> onleftClick = null, List <IFlatListItem> stacks = null, string key = null) { if (!composer.Composed) { composer.AddInteractiveElement(new GuiElementFlatList(composer.Api, bounds, onleftClick, stacks), key); } return(composer); }
private static void UpdateMapGui(GuiComposer composer, Vec3d pos) { var map = (GuiElementMap)composer.GetElement("mapElem"); map.CurrentBlockViewBounds.X1 = pos.X - map.Bounds.InnerWidth / 2.0 / map.ZoomLevel; map.CurrentBlockViewBounds.Z1 = pos.Z - map.Bounds.InnerHeight / 2.0 / map.ZoomLevel; map.CurrentBlockViewBounds.X2 = pos.X + map.Bounds.InnerWidth / 2.0 / map.ZoomLevel; map.CurrentBlockViewBounds.Z2 = pos.Z + map.Bounds.InnerHeight / 2.0 / map.ZoomLevel; map.EnsureMapFullyLoaded(); }
private void UpdateStats() { EntityPlayer entity = capi.World.Player.Entity; GuiComposer compo = Composers["playerstats"]; if (compo == null || !IsOpened()) { return; } float?health; float?maxhealth; float?saturation; float?maxsaturation; getHealthSat(out health, out maxhealth, out saturation, out maxsaturation); float walkspeed = entity.Stats.GetBlended("walkspeed"); float healingEffectivness = entity.Stats.GetBlended("healingeffectivness"); float hungerRate = entity.Stats.GetBlended("hungerrate"); float rangedWeaponAcc = entity.Stats.GetBlended("rangedWeaponsAcc"); float rangedWeaponSpeed = entity.Stats.GetBlended("rangedWeaponsSpeed"); if (health != null) { compo.GetDynamicText("health").SetNewText((health + " / " + maxhealth)); } if (saturation != null) { compo.GetDynamicText("satiety").SetNewText((int)saturation + " / " + (int)maxsaturation); } compo.GetDynamicText("walkspeed").SetNewText((int)Math.Round(100 * walkspeed) + "%"); compo.GetDynamicText("healeffectiveness").SetNewText((int)Math.Round(100 * healingEffectivness) + "%"); compo.GetDynamicText("hungerrate")?.SetNewText((int)Math.Round(100 * hungerRate) + "%"); compo.GetDynamicText("rangedweaponacc").SetNewText((int)Math.Round(100 * rangedWeaponAcc) + "%"); compo.GetDynamicText("rangedweaponchargespeed").SetNewText((int)Math.Round(100 * rangedWeaponSpeed) + "%"); ITreeAttribute tempTree = entity.WatchedAttributes.GetTreeAttribute("bodyTemp"); compo.GetRichtext("bodytemp").SetNewText(getBodyTempText(tempTree), CairoFont.WhiteDetailText()); }
private void UpdateStatBars() { GuiComposer compo = Composers["playerstats"]; if (compo == null || !IsOpened()) { return; } ITreeAttribute hungerTree = capi.World.Player.Entity.WatchedAttributes.GetTreeAttribute("hunger"); if (hungerTree != null) { float saturation = hungerTree.GetFloat("currentsaturation"); float maxSaturation = hungerTree.GetFloat("maxsaturation"); float fruitLevel = hungerTree.GetFloat("fruitLevel"); float vegetableLevel = hungerTree.GetFloat("vegetableLevel"); float grainLevel = hungerTree.GetFloat("grainLevel"); float proteinLevel = hungerTree.GetFloat("proteinLevel"); float dairyLevel = hungerTree.GetFloat("dairyLevel"); compo.GetDynamicText("satiety").SetNewText((int)saturation + " / " + maxSaturation); Composers["playerstats"].GetStatbar("fruitBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("vegetableBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("grainBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("proteinBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("dairyBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("fruitBar").SetValues(fruitLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("vegetableBar").SetValues(vegetableLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("grainBar").SetValues(grainLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("proteinBar").SetValues(proteinLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("dairyBar").SetValues(dairyLevel, 0, maxSaturation); } }
public void initOverviewGui() { ElementBounds searchFieldBounds = ElementBounds.Fixed(GuiStyle.ElementToDialogPadding - 2, 45, 300, 30); ElementBounds stackListBounds = ElementBounds.Fixed(0, 0, 500, listHeight).FixedUnder(searchFieldBounds, 5); ElementBounds clipBounds = stackListBounds.ForkBoundingParent(); ElementBounds insetBounds = stackListBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stackListBounds.fixedWidth + 7).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 8) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(2, 0) ; // 2. Around all that is 10 pixel padding ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(insetBounds, stackListBounds, scrollbarBounds, closeButtonBounds); // 3. Finally Dialog ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.None).WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0, 70); ElementBounds tabBounds = ElementBounds.Fixed(-200, 35, 200, 545); int curTab; ElementBounds backButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.LeftFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(-6, 3) ; overviewGui = capi.Gui .CreateCompo("handbook-overview", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Survival Handbook"), OnTitleBarClose) .AddVerticalTabs(genTabs(out curTab), tabBounds, OnTabClicked, "verticalTabs") .AddTextInput(searchFieldBounds, FilterItemsBySearchText, CairoFont.WhiteSmallishText(), "searchField") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddHandbookStackList(stackListBounds, onLeftClickListElement, shownHandbookPages, "stacklist") .EndClip() .AddVerticalScrollbar(OnNewScrollbarvalueOverviewPage, scrollbarBounds, "scrollbar") .AddSmallButton(Lang.Get("general-back"), OnButtonBack, backButtonBounds, EnumButtonStyle.Normal, EnumTextOrientation.Center, "backButton") .AddSmallButton(Lang.Get("Close Handbook"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; overviewGui.GetScrollbar("scrollbar").SetHeights( (float)listHeight, (float)overviewGui.GetHandbookStackList("stacklist").insideBounds.fixedHeight ); overviewGui.GetTextInput("searchField").SetPlaceHolderText("Search..."); overviewGui.GetVerticalTab("verticalTabs").SetValue(curTab, false); overviewGui.FocusElement(overviewGui.GetTextInput("searchField").TabIndex); if (curTab == 0) { currentCatgoryCode = null; } else { currentCatgoryCode = categoryCodes[curTab - 1]; } FilterItems(); }
void initDetailGui() { ElementBounds textBounds = ElementBounds.Fixed(9, 45, 500, 30 + listHeight + 17); ElementBounds clipBounds = textBounds.ForkBoundingParent(); ElementBounds insetBounds = textBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = clipBounds.CopyOffsetedSibling(textBounds.fixedWidth + 7, -6, 0, 6).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(-11, 1) ; ElementBounds backButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.LeftFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(4, 1) ; ElementBounds overviewButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.CenterFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(0, 1) ; ElementBounds bgBounds = insetBounds.ForkBoundingParent(5, 40, 36, 52).WithFixedPadding(GuiStyle.ElementToDialogPadding / 2); bgBounds.WithChildren(insetBounds, textBounds, scrollbarBounds, backButtonBounds, closeButtonBounds); BrowseHistoryElement curPage = browseHistory.Peek(); float posY = curPage.PosY; // 3. Finally Dialog ElementBounds dialogBounds = bgBounds.ForkBoundingParent().WithAlignment(EnumDialogArea.None).WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0, 70); //dialogBounds.Code = "dialogbounds"; RichTextComponentBase[] cmps = curPage.Page.GetPageText(capi, allstacks, OpenDetailPageFor); int curTab; ElementBounds tabBounds = ElementBounds.Fixed(-200, 35, 200, 545); detailViewGui?.Dispose(); detailViewGui = capi.Gui .CreateCompo("handbook-detail", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Survival Handbook"), OnTitleBarClose) .AddVerticalTabs(genTabs(out curTab), tabBounds, OnDetailViewTabClicked, "verticalTabs") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddRichtext(cmps, textBounds, "richtext") .EndClip() .AddVerticalScrollbar(OnNewScrollbarvalueDetailPage, scrollbarBounds, "scrollbar") .AddSmallButton(Lang.Get("general-back"), OnButtonBack, backButtonBounds) .AddSmallButton(Lang.Get("handbook-overview"), OnButtonOverview, overviewButtonBounds) .AddSmallButton(Lang.Get("general-close"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; GuiElementRichtext richtextelem = detailViewGui.GetRichtext("richtext"); detailViewGui.GetScrollbar("scrollbar").SetHeights( (float)listHeight, (float)richtextelem.Bounds.fixedHeight ); detailViewGui.GetScrollbar("scrollbar").CurrentYPosition = posY; OnNewScrollbarvalueDetailPage(posY); detailViewGui.GetVerticalTab("verticalTabs").SetValue(curTab, false); }
void initOverviewGui() { ElementBounds searchFieldBounds = ElementBounds.Fixed(GuiStyle.ElementToDialogPadding - 2, 45, 300, 30); ElementBounds stackListBounds = ElementBounds.Fixed(0, 0, 400, listHeight).FixedUnder(searchFieldBounds, 5); ElementBounds clipBounds = stackListBounds.ForkBoundingParent(); ElementBounds insetBounds = stackListBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stackListBounds.fixedWidth + 7).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 8) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(2, 0) ; // 2. Around all that is 10 pixel padding ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(insetBounds, stackListBounds, scrollbarBounds, closeButtonBounds); // 3. Finally Dialog ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle); ElementBounds tabBounds = ElementBounds.Fixed(-130, 35, 130, 545); GuiTab[] tabs = new GuiTab[2]; tabs[0] = new GuiTab() { DataInt = 0, Name = Lang.Get("Blocks and Items"), }; tabs[1] = new GuiTab() { DataInt = 1, Name = Lang.Get("Crafting mechanics") }; overviewGui = capi.Gui .CreateCompo("handbook-overview", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Survival Handbook"), OnTitleBarClose) //.AddVerticalTabs(tabs, tabBounds, OnTabClicked, "verticalTabs") .AddTextInput(searchFieldBounds, FilterItemsBySearchText, CairoFont.WhiteSmallishText(), "searchField") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddHandbookStackList(stackListBounds, onLeftClickListElement, listElements, "stacklist") .EndClip() .AddVerticalScrollbar(OnNewScrollbarvalueOverviewPage, scrollbarBounds, "scrollbar") .AddSmallButton(Lang.Get("Close Handbook"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; overviewGui.GetScrollbar("scrollbar").SetHeights( (float)listHeight, (float)overviewGui.GetHandbookStackList("stacklist").insideBounds.fixedHeight ); }
public static GuiElementFlatList GetFlatList(this GuiComposer composer, string key) { return((GuiElementFlatList)composer.GetElement(key)); }
private void composeTraitsTab(GuiComposer compo) { compo .AddRichtext(getClassTraitText(), CairoFont.WhiteDetailText().WithLineHeightMultiplier(1.15), ElementBounds.Fixed(0, 25, 385, 200)); }
void initDetailGui() { ElementBounds textBounds = ElementBounds.Fixed(9, 45, 500, 30 + listHeight + 17); ElementBounds clipBounds = textBounds.ForkBoundingParent(); ElementBounds insetBounds = textBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = clipBounds.CopyOffsetedSibling(textBounds.fixedWidth + 7, -6, 0, 6).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(-11, 1) ; ElementBounds backButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.LeftFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(4, 1) ; ElementBounds overviewButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.CenterFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(0, 1) ; ElementBounds bgBounds = insetBounds.ForkBoundingParent(5, 40, 36, 52).WithFixedPadding(GuiStyle.ElementToDialogPadding / 2); bgBounds.WithChildren(insetBounds, textBounds, scrollbarBounds, backButtonBounds, closeButtonBounds); BrowseHistoryElement curPage = browseHistory.Peek(); float posY = curPage.PosY; // 3. Finally Dialog ElementBounds dialogBounds = bgBounds.ForkBoundingParent().WithAlignment(EnumDialogArea.None).WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0, 70); //dialogBounds.Code = "dialogbounds"; int curTab; ElementBounds tabBounds = ElementBounds.Fixed(-200, 35, 200, 545); string essence = ""; int num; if (pageNumberByPageCode.TryGetValue(curPage.Page.PageCode, out num)) { essence = essenceItemName[num]; essence += "\n\n"; essence += GetEssences(curPage.Page.PageCode); } detailViewGui?.Dispose(); detailViewGui = capi.Gui .CreateCompo("essence-handbook-detail", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Potion Essence Handbook"), OnTitleBarClose) .AddVerticalTabs(genTabs(out curTab), tabBounds, OnDetailViewTabClicked, "verticalTabs") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddStaticText(Lang.Get(essence), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), textBounds) .EndClip() .AddSmallButton(Lang.Get("general-back"), OnButtonBack, backButtonBounds) .AddSmallButton(Lang.Get("essence-handbook-overview"), OnButtonOverview, overviewButtonBounds) .AddSmallButton(Lang.Get("general-close"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; detailViewGui.GetVerticalTab("verticalTabs").SetValue(curTab, false); }