Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add library for creating GUI menus #370

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1148314
Create gui_menu.sc
Ghoulboy78 Apr 6, 2023
a4db6da
Getting rid of previous test functions
Ghoulboy78 Apr 6, 2023
8bf50b4
Rearranged code, made prettier example
Ghoulboy78 Apr 6, 2023
15e45e5
Adding dynamic buttons (+ examples)
Ghoulboy78 Apr 6, 2023
9c4f693
editing testing tools
Ghoulboy78 Apr 6, 2023
9fe65df
Adding storage slots
Ghoulboy78 Apr 7, 2023
054ea20
Bugfix
Ghoulboy78 Apr 7, 2023
ebb23da
adding player variable in button action callback
Ghoulboy78 Apr 7, 2023
1bdfce2
Switching from map to list
Ghoulboy78 Apr 7, 2023
989c917
Framework for pages functionality
Ghoulboy78 Apr 8, 2023
2a6b878
Added page switching funcionality
Ghoulboy78 Apr 9, 2023
7f965b8
Added ability for different pages to have different titles
Ghoulboy78 Apr 10, 2023
e07d2fb
Different pages can have different inventory sizes!
Ghoulboy78 Apr 10, 2023
f1647e8
Fixed bug which allowed player to mess up screen
Ghoulboy78 Apr 10, 2023
a65370d
Added button labels
Ghoulboy78 Apr 10, 2023
1703bef
Fixed bug causing incorrect inventory shape opened incase of nondefau…
Ghoulboy78 Apr 10, 2023
ac88016
Renaming to .scl and removing testing stuff
Ghoulboy78 Apr 10, 2023
19d4ebc
Added ability to have all types of gui screen
Ghoulboy78 Apr 10, 2023
cb0ac79
Added callback for anvil GUI modification
Ghoulboy78 Apr 10, 2023
ffa42d0
Giving more info with anvil item modification
Ghoulboy78 Apr 10, 2023
18f1dbf
Added select_recipe events
Ghoulboy78 Apr 10, 2023
f484d7b
Added dynamic slots
Ghoulboy78 Apr 11, 2023
a8b34e2
Added additional screen callback for programmers
Ghoulboy78 Apr 11, 2023
c8a4f96
Added loom pattern selection
Ghoulboy78 Apr 11, 2023
8767362
Added stonecutter and loom functionality
Ghoulboy78 Apr 11, 2023
f11babf
Extracted page switching to new function
Ghoulboy78 Apr 11, 2023
c905785
Added lectern button detection
Ghoulboy78 Apr 11, 2023
4086355
Fixing bug with dynamic slots
Ghoulboy78 Apr 11, 2023
55810ce
Added enchantment table function
Ghoulboy78 Jun 23, 2023
89c4396
Removed name placeholders
Ghoulboy78 Jun 23, 2023
8c18bd0
Added descriptive documentation
Ghoulboy78 Jun 26, 2023
79d297d
Added on_init
Ghoulboy78 Jun 26, 2023
438cfbd
Create test_gui_menu.sc
Ghoulboy78 Jun 26, 2023
0f2d8b9
Added `on_select_crafting_recipe` event to furnace/blast furnace/smok…
Ghoulboy78 Aug 3, 2023
6fac304
returning proper icon item array
Ghoulboy78 Dec 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding dynamic buttons (+ examples)
Also changing from stained glass to stained glass panes
  • Loading branch information
Ghoulboy78 committed Apr 6, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 15e45e59d0b2677aee932f28a1fb0cfdec44ed72
24 changes: 21 additions & 3 deletions programs/fundamentals/gui_menu.sc
Original file line number Diff line number Diff line change
@@ -19,13 +19,26 @@ global_inventory_sizes={

//Certain names are subject to change, so instead I'll store them in global variables while I'm still fiddling with exact nomenclature
global_static_buttons='buttons';
global_dynamic_buttons='dynamic_buttons';

global_Test={
'inventory_shape'->'generic_3x3',
'title'->format('db Test GUI menu!'),
global_static_buttons->{
0->['red_stained_glass', _(button)->print('Pressed the red button!')],
4->['green_stained_glass', _(button)->print(str('Clicked with %s button', if(button, 'Right', 'Left')))]
0->['red_stained_glass_pane', _(button)->print('Pressed the red button!')],
4->['green_stained_glass_pane', _(button)->print(str('Clicked with %s button', if(button, 'Right', 'Left')))]
},
global_dynamic_buttons->{
1->{ //Blue button to black button
'icon'->'blue_stained_glass_pane',
'action'->_(screen)->inventory_set(screen, 1, 1, if(inventory_get(screen, 1):0=='blue_stained_glass_pane', 'black_stained_glass_pane', 'blue_stained_glass_pane'));
},
6->{ //Turns the slot above purple
'icon'->'lime_stained_glass_pane',
'action'->_(screen)->(
inventory_set(screen, 3, 1, if(inventory_get(screen, 3)==null, 'purple_stained_glass_pane', 'air'));
)
}
}
};

@@ -50,6 +63,9 @@ new_gui_menu(gui_screen)->( //Stores GUI data in intermediary map form, so the p
for(gui_screen:global_static_buttons,
inventory_set(screen, _, 1, gui_screen:global_static_buttons:_:0)
);
for(gui_screen:global_dynamic_buttons,
inventory_set(screen, _, 1, gui_screen:global_dynamic_buttons:_:'icon')
);
),
'callback'->_(screen, player, action, data, outer(gui_screen), outer(inventory_size))->(//This is where most of the action happens
if(action=='quick_move', //disabling quick move cos it messes up the GUI, and there's no reason to allow it
@@ -61,7 +77,9 @@ new_gui_menu(gui_screen)->( //Stores GUI data in intermediary map form, so the p
if(action=='pickup', //This is equivalent of clicking (button action)

if(has(gui_screen:global_static_buttons, slot), //Plain, vanilla button
call(gui_screen:global_static_buttons:slot:1, data:'button')
call(gui_screen:global_static_buttons:slot:1, data:'button'),
has(gui_screen:global_dynamic_buttons, slot), //A more exciting button
call(gui_screen:global_dynamic_buttons:slot:'action', screen)
);
);