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
52924768
Commit
52924768
authored
12 years ago
by
Ilya Zhuravlev
Browse files
Options
Downloads
Plain Diff
Merge pull request #284 from RealBadAngel/master
Adding backgrounds to formspec
parents
1db03347
8e5167d7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/lua_api.txt
+5
-0
5 additions, 0 deletions
doc/lua_api.txt
src/guiFormSpecMenu.cpp
+43
-2
43 additions, 2 deletions
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h
+1
-0
1 addition, 0 deletions
src/guiFormSpecMenu.h
with
49 additions
and
2 deletions
doc/lua_api.txt
+
5
−
0
View file @
52924768
...
...
@@ -694,6 +694,11 @@ image[<X>,<Y>;<W>,<H>;<texture name>]
^ Show an image
^ Position and size units are inventory slots
background[<X>,<Y>;<W>,<H>;<texture name>]
^ Use a background. Inventory rectangles are not drawn then.
^ Position and size units are inventory slots
^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px
field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
^ Textual field; will be sent to server when a button is clicked
^ x and y position the field relative to the top left of the menu
...
...
This diff is collapsed.
Click to expand it.
src/guiFormSpecMenu.cpp
+
43
−
2
View file @
52924768
...
...
@@ -199,6 +199,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
m_inventorylists
.
clear
();
m_images
.
clear
();
m_backgrounds
.
clear
();
m_fields
.
clear
();
Strfnd
f
(
m_formspec_string
);
...
...
@@ -278,9 +279,26 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
<<
", geom=("
<<
geom
.
X
<<
","
<<
geom
.
Y
<<
")"
<<
std
::
endl
;
if
(
bp_set
!=
2
)
errorstream
<<
"WARNING: invalid use of
button
without a size[] element"
<<
std
::
endl
;
errorstream
<<
"WARNING: invalid use of
image
without a size[] element"
<<
std
::
endl
;
m_images
.
push_back
(
ImageDrawSpec
(
name
,
pos
,
geom
));
}
else
if
(
type
==
"background"
)
{
v2s32
pos
=
basepos
;
pos
.
X
+=
stof
(
f
.
next
(
","
))
*
(
float
)
spacing
.
X
-
((
float
)
spacing
.
X
-
(
float
)
imgsize
.
X
)
/
2
;
pos
.
Y
+=
stof
(
f
.
next
(
";"
))
*
(
float
)
spacing
.
Y
-
((
float
)
spacing
.
Y
-
(
float
)
imgsize
.
Y
)
/
2
;
v2s32
geom
;
geom
.
X
=
stof
(
f
.
next
(
","
))
*
(
float
)
spacing
.
X
;
geom
.
Y
=
stof
(
f
.
next
(
";"
))
*
(
float
)
spacing
.
Y
;
std
::
string
name
=
f
.
next
(
"]"
);
infostream
<<
"image name="
<<
name
<<
", pos=("
<<
pos
.
X
<<
","
<<
pos
.
Y
<<
")"
<<
", geom=("
<<
geom
.
X
<<
","
<<
geom
.
Y
<<
")"
<<
std
::
endl
;
if
(
bp_set
!=
2
)
errorstream
<<
"WARNING: invalid use of background without a size[] element"
<<
std
::
endl
;
m_backgrounds
.
push_back
(
ImageDrawSpec
(
name
,
pos
,
geom
));
}
else
if
(
type
==
"field"
)
{
std
::
string
fname
=
f
.
next
(
";"
);
...
...
@@ -691,6 +709,26 @@ void GUIFormSpecMenu::drawMenu()
m_tooltip_element
->
setVisible
(
false
);
/*
Draw backgrounds
*/
for
(
u32
i
=
0
;
i
<
m_backgrounds
.
size
();
i
++
)
{
const
ImageDrawSpec
&
spec
=
m_backgrounds
[
i
];
video
::
ITexture
*
texture
=
m_gamedef
->
tsrc
()
->
getTextureRaw
(
spec
.
name
);
// Image size on screen
core
::
rect
<
s32
>
imgrect
(
0
,
0
,
spec
.
geom
.
X
,
spec
.
geom
.
Y
);
// Image rectangle on screen
core
::
rect
<
s32
>
rect
=
imgrect
+
spec
.
pos
;
const
video
::
SColor
color
(
255
,
255
,
255
,
255
);
const
video
::
SColor
colors
[]
=
{
color
,
color
,
color
,
color
};
driver
->
draw2DImage
(
texture
,
rect
,
core
::
rect
<
s32
>
(
core
::
position2d
<
s32
>
(
0
,
0
),
core
::
dimension2di
(
texture
->
getOriginalSize
())),
NULL
/*&AbsoluteClippingRect*/
,
colors
,
true
);
}
/*
Draw images
*/
...
...
@@ -715,8 +753,11 @@ void GUIFormSpecMenu::drawMenu()
Draw items
Phase 0: Item slot rectangles
Phase 1: Item images; prepare tooltip
If backgrounds used, do not draw Item slot rectangles
*/
for
(
int
phase
=
0
;
phase
<=
1
;
phase
++
)
int
start_phase
=
0
;
if
(
m_backgrounds
.
size
()
>
0
)
start_phase
=
1
;
for
(
int
phase
=
start_phase
;
phase
<=
1
;
phase
++
)
for
(
u32
i
=
0
;
i
<
m_inventorylists
.
size
();
i
++
)
{
drawList
(
m_inventorylists
[
i
],
phase
);
...
...
This diff is collapsed.
Click to expand it.
src/guiFormSpecMenu.h
+
1
−
0
View file @
52924768
...
...
@@ -206,6 +206,7 @@ class GUIFormSpecMenu : public GUIModalMenu
TextDest
*
m_text_dst
;
core
::
array
<
ListDrawSpec
>
m_inventorylists
;
core
::
array
<
ImageDrawSpec
>
m_backgrounds
;
core
::
array
<
ImageDrawSpec
>
m_images
;
core
::
array
<
FieldSpec
>
m_fields
;
...
...
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