gui tables problems

Place to get help with not working mods / modding interface.
Post Reply
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

gui tables problems

Post by L0771 »

Hi, i have some problems making a mod (lots of problems Xd)
On gui my problem is the alignment, i want all tables in a same height...
I have this
Now have this
and want something like this
Want this
Or better () 8-)
When i put a table inside other table, the first table is going out of screen ...

Talents row is a desplegable menu, and if i close all talents menus shows this
0
Thanks for the help

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: gui tables problems

Post by rk84 »

I'm not sure how you have set it up, so it might help if you post the code. Center gui? Possibly table (a GUI element type) with colspan of 6 could keep form better?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: gui tables problems

Post by L0771 »

it's so extensive

First call a table on left, on the left of this table the main window

Code: Select all

local gui = cursed[game.player.name].gui
gui.tableMain = game.player.gui.left.add{ type="table", name="tableMain", colspan=2 }
gui.tableMainS = true
local frameTalentsMain = gui.tableMain.add{ type="frame", name="frameTalentsMain", direction = "vertical" }
local tableTalentsMain = frameTalentsMain.add{ type="table", name="tableTalentsMain", colspan=1 }
tableTalentsMain.add({ type="label", name="main", caption = "cursed", style = "recipe_tooltip_cannot_craft_label_style" })
tableTalentsMain.add({ type="button", name="talentsMain", caption = "Talents", style = "dialog_button_style" })
tableTalentsMain.add({ type="button", name="statsMain", caption = "Stats", style = "dialog_button_style" })
tableTalentsMain.add({ type="button", name="buildsMain", caption = "Builds", style = "dialog_button_style" })
tableTalentsMain.add({ type="button", name="activesMain", caption = "Activables", style = "dialog_button_style" })
Here when click a button add a frame in the first table (if is open, this windows closes), every button is in a different table, when clicked a "Talent #", this table is added here below
I want the this table aligned on top of first table, but now is centered

Code: Select all

if name == "talentsMain" then
	closeAllMain(1)
	if gui.frameTalentsS then
		gui.frameTalents.destroy()
		gui.frameTalentsS = false
		closeAllTalents(-1)
	else
		gui.frameTalents = gui.tableMain.add{ type="frame", name="frameTalents", direction = "horizontal", style = "outer_frame_style" }
		gui.frameTalentsS = true
		local tableTalents = gui.frameTalents.add{ type="table", name="tableTalents", colspan=6 }
		gui.frameTalentsDet1 = tableTalents.add{ type="frame", name="frameTalents1", direction = "vertical" }
		gui.frameTalentsDet1.add({ type="button", name="talentsMain1", caption = "Talents 1 (" .. game.player.getitemcount("cursed-talent-1") .. ")", style = "talents_bar_button1" })
		gui.frameTalentsDet2 = tableTalents.add{ type="frame", name="frameTalents2", direction = "vertical" }
		gui.frameTalentsDet2.add({ type="button", name="talentsMain2", caption = "Talents 2 (" .. game.player.getitemcount("cursed-talent-2") .. ")", style = "talents_bar_button1" })
		gui.frameTalentsDet3 = tableTalents.add{ type="frame", name="frameTalents3", direction = "vertical" }
		gui.frameTalentsDet3.add({ type="button", name="talentsMain3", caption = "Talents 3 (" .. game.player.getitemcount("cursed-talent-3") .. ")", style = "talents_bar_button1" })
		gui.frameTalentsDet4 = tableTalents.add{ type="frame", name="frameTalents4", direction = "vertical" }
		gui.frameTalentsDet4.add({ type="button", name="talentsMain4", caption = "Talents 4 (" .. game.player.getitemcount("cursed-talent-4") .. ")", style = "talents_bar_button1" })
		gui.frameTalentsDet5 = tableTalents.add{ type="frame", name="frameTalents5", direction = "vertical" }
		gui.frameTalentsDet5.add({ type="button", name="talentsMain5", caption = "Talents 5 (" .. game.player.getitemcount("cursed-talent-5") .. ")", style = "talents_bar_button1" })
		gui.frameTalentsDet6 = tableTalents.add{ type="frame", name="frameTalents6", direction = "vertical" }
		gui.frameTalentsDet6.add({ type="button", name="talentsMain6", caption = "Talents 6 (" .. game.player.getitemcount("cursed-talent-6") .. ")", style = "talents_bar_button1" })
	end
end
When click a "Talent #" add some like this

Code: Select all

	elseif name == "talentsMain1" then
	closeAllTalents(1)
		if gui.tableTalents1S then
			gui.tableTalents1.destroy()
			gui.tableTalents1S = false
		else
			gui.tableTalents1 = gui.frameTalentsDet1.add{ type="table", name="tableTalents1", colspan=1 }
			gui.tableTalents1S = true
			gui.tableTalents1.add({ type="button", name="talent1c1", caption = "24hs day (" .. talents[1][1].now .. "/" .. talents[1][1].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c2", caption = "24hs night (" .. talents[1][2].now .. "/" .. talents[1][2].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c3", caption = "24hs easy (" .. talents[1][3].now .. "/" .. talents[1][3].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c4", caption = "24hs hard (" .. talents[1][4].now .. "/" .. talents[1][4].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c5", caption = "Mining bonus (" .. talents[1][5].now .. "/" .. talents[1][5].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c6", caption = "Farming bonus (" .. talents[1][6].now .. "/" .. talents[1][6].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c7", caption = "Crafting bonus (" .. talents[1][7].now .. "/" .. talents[1][7].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c8", caption = "Explore bonus (" .. talents[1][8].now .. "/" .. talents[1][8].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c9", caption = "Attack bonus (" .. talents[1][9].now .. "/" .. talents[1][9].max .. ")", style = "" })
			gui.tableTalents1.add({ type="button", name="talent1c10", caption = "Defense bonus (" .. talents[1][10].now .. "/" .. talents[1][10].max .. ")", style = "" })
		end
	end
I uploaded my mod here, but I have this problem even :oops:

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: gui tables problems

Post by rk84 »

I was going to reply yesterday day, but it was too extensive for my phone. I accidently removed my reply, desided to just close the browser and go to sleep :)

I see the problem is quite opposite what I first though. The way you use the table. Single cell filled with elements can stretch neighboring cells. I also noticed you used table with colspan=1. You could use flow type with vertical direction to get same effect. Flow is like invisible frame.

I would suggest you use flow with horizontal direction as base of your gui and then add frames with vertical direction to create lists of buttons/labels.

partial example. (Lines 1642-1654)

Code: Select all

local gui = cursed[game.player.name].gui
    gui.tableMain = game.player.gui.left.add{ type="flow", name="tableMain", direction=horizontal }
    gui.tableMainS = true
    local frameTalentsMain = gui.tableMain.add{ type="frame", name="frameTalentsMain", direction = "vertical" }
    local tableTalentsMain = frameTalentsMain.add{ type="flow", name="tableTalentsMain", direction="vertical" }
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: gui tables problems

Post by L0771 »

I like this! i used flow on menu, and now i have exactly what i want :)
And now i haven't a invisible frame using all my screen, flow is unclickeable :D
Thanks you

Image

Post Reply

Return to “Modding help”