Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
a09d86dd
Commit
a09d86dd
authored
12 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Update inventory menu from formspec on-the-fly
parent
3ccb0f69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game.cpp
+24
-0
24 additions, 0 deletions
src/game.cpp
src/guiInventoryMenu.cpp
+17
-10
17 additions, 10 deletions
src/guiInventoryMenu.cpp
src/guiInventoryMenu.h
+14
-0
14 additions, 0 deletions
src/guiInventoryMenu.h
with
55 additions
and
10 deletions
src/game.cpp
+
24
−
0
View file @
a09d86dd
...
...
@@ -132,6 +132,28 @@ class MainRespawnInitiator: public IRespawnInitiator
Client
*
m_client
;
};
/* Form update callback */
class
NodeMetadataFormSource
:
public
IFormSource
{
public:
NodeMetadataFormSource
(
ClientMap
*
map
,
v3s16
p
)
:
m_map
(
map
),
m_p
(
p
)
{
}
std
::
string
getForm
()
{
NodeMetadata
*
meta
=
m_map
->
getNodeMetadata
(
m_p
);
if
(
!
meta
)
return
""
;
return
meta
->
getString
(
"formspec"
);
}
ClientMap
*
m_map
;
v3s16
m_p
;
};
/*
Hotbar draw routine
*/
...
...
@@ -2348,6 +2370,8 @@ void the_game(
&
client
,
gamedef
);
menu
->
setFormSpec
(
meta
->
getString
(
"formspec"
),
inventoryloc
);
menu
->
setFormSource
(
new
NodeMetadataFormSource
(
&
client
.
getEnv
().
getClientMap
(),
nodepos
));
menu
->
drop
();
}
// Otherwise report right click to server
...
...
This diff is collapsed.
Click to expand it.
src/guiInventoryMenu.cpp
+
17
−
10
View file @
a09d86dd
...
...
@@ -126,23 +126,24 @@ GUIInventoryMenu::GUIInventoryMenu(gui::IGUIEnvironment* env,
IMenuManager
*
menumgr
,
InventoryManager
*
invmgr
,
IGameDef
*
gamedef
)
:
)
:
GUIModalMenu
(
env
,
parent
,
id
,
menumgr
),
m_invmgr
(
invmgr
),
m_gamedef
(
gamedef
)
m_gamedef
(
gamedef
),
m_form_src
(
NULL
),
m_selected_item
(
NULL
),
m_selected_amount
(
0
),
m_selected_dragging
(
false
),
m_tooltip_element
(
NULL
)
{
m_selected_item
=
NULL
;
m_selected_amount
=
0
;
m_selected_dragging
=
false
;
m_tooltip_element
=
NULL
;
}
GUIInventoryMenu
::~
GUIInventoryMenu
()
{
removeChildren
();
if
(
m_selected_item
)
delete
m_
selected_item
;
delete
m_selected_item
;
delete
m_
form_src
;
}
void
GUIInventoryMenu
::
removeChildren
()
...
...
@@ -244,8 +245,6 @@ void GUIInventoryMenu::regenerateGui(v2u32 screensize)
pos
.
X
+=
stof
(
f
.
next
(
","
))
*
(
float
)
spacing
.
X
;
pos
.
Y
+=
stof
(
f
.
next
(
";"
))
*
(
float
)
spacing
.
Y
;
v2s32
geom
;
/*geom.X = imgsize.X + ((stoi(f.next(","))-1) * spacing.X);
geom.Y = imgsize.Y + ((stoi(f.next(";"))-1) * spacing.Y);*/
geom
.
X
=
stof
(
f
.
next
(
","
))
*
(
float
)
imgsize
.
X
;
geom
.
Y
=
stof
(
f
.
next
(
";"
))
*
(
float
)
imgsize
.
Y
;
std
::
string
name
=
f
.
next
(
"]"
);
...
...
@@ -430,6 +429,14 @@ void GUIInventoryMenu::drawSelectedItem()
void
GUIInventoryMenu
::
drawMenu
()
{
if
(
m_form_src
){
std
::
string
newform
=
m_form_src
->
getForm
();
if
(
newform
!=
m_formspec_string
){
m_formspec_string
=
newform
;
regenerateGui
(
m_screensize_old
);
}
}
updateSelectedItem
();
gui
::
IGUISkin
*
skin
=
Environment
->
getSkin
();
...
...
This diff is collapsed.
Click to expand it.
src/guiInventoryMenu.h
+
14
−
0
View file @
a09d86dd
...
...
@@ -30,6 +30,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class
IGameDef
;
class
InventoryManager
;
class
IFormSource
{
public:
virtual
~
IFormSource
(){}
virtual
std
::
string
getForm
()
=
0
;
};
void
drawItemStack
(
video
::
IVideoDriver
*
driver
,
gui
::
IGUIFont
*
font
,
const
ItemStack
&
item
,
...
...
@@ -117,6 +124,12 @@ class GUIInventoryMenu : public GUIModalMenu
m_current_inventory_location
=
current_inventory_location
;
regenerateGui
(
m_screensize_old
);
}
// form_src is deleted by this GUIInventoryMenu
void
setFormSource
(
IFormSource
*
form_src
)
{
m_form_src
=
form_src
;
}
void
removeChildren
();
/*
...
...
@@ -147,6 +160,7 @@ class GUIInventoryMenu : public GUIModalMenu
std
::
string
m_formspec_string
;
InventoryLocation
m_current_inventory_location
;
IFormSource
*
m_form_src
;
core
::
array
<
ListDrawSpec
>
m_inventorylists
;
core
::
array
<
ImageDrawSpec
>
m_images
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment