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
d702a2c3
Commit
d702a2c3
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Made the initial loading screen slightly more alive
parent
7e59938c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/game.cpp
+52
-25
52 additions, 25 deletions
src/game.cpp
with
52 additions
and
25 deletions
src/game.cpp
+
52
−
25
View file @
d702a2c3
...
...
@@ -639,6 +639,34 @@ void update_skybox(video::IVideoDriver* driver,
}
}
/*
Draws a screen with a single text on it.
Text will be removed when the screen is drawn the next time.
*/
/*gui::IGUIStaticText **/
void
draw_load_screen
(
const
std
::
wstring
&
text
,
video
::
IVideoDriver
*
driver
,
gui
::
IGUIFont
*
font
)
{
v2u32
screensize
=
driver
->
getScreenSize
();
const
wchar_t
*
loadingtext
=
text
.
c_str
();
core
::
vector2d
<
u32
>
textsize_u
=
font
->
getDimension
(
loadingtext
);
core
::
vector2d
<
s32
>
textsize
(
textsize_u
.
X
,
textsize_u
.
Y
);
core
::
vector2d
<
s32
>
center
(
screensize
.
X
/
2
,
screensize
.
Y
/
2
);
core
::
rect
<
s32
>
textrect
(
center
-
textsize
/
2
,
center
+
textsize
/
2
);
gui
::
IGUIStaticText
*
guitext
=
guienv
->
addStaticText
(
loadingtext
,
textrect
,
false
,
false
);
guitext
->
setTextAlignment
(
gui
::
EGUIA_CENTER
,
gui
::
EGUIA_UPPERLEFT
);
driver
->
beginScene
(
true
,
true
,
video
::
SColor
(
255
,
0
,
0
,
0
));
guienv
->
drawAll
();
driver
->
endScene
();
guitext
->
remove
();
//return guitext;
}
void
the_game
(
bool
&
kill
,
bool
random_input
,
...
...
@@ -655,6 +683,9 @@ void the_game(
{
video
::
IVideoDriver
*
driver
=
device
->
getVideoDriver
();
scene
::
ISceneManager
*
smgr
=
device
->
getSceneManager
();
// Calculate text height using the font
u32
text_height
=
font
->
getDimension
(
L"Random test string"
).
Height
;
v2u32
screensize
(
0
,
0
);
v2u32
last_screensize
(
0
,
0
);
...
...
@@ -674,20 +705,10 @@ void the_game(
/*
Draw "Loading" screen
*/
const
wchar_t
*
loadingtext
=
L"Loading and connecting..."
;
u32
text_height
=
font
->
getDimension
(
loadingtext
).
Height
;
core
::
vector2d
<
s32
>
center
(
screensize
.
X
/
2
,
screensize
.
Y
/
2
);
core
::
vector2d
<
s32
>
textsize
(
300
,
text_height
);
core
::
rect
<
s32
>
textrect
(
center
-
textsize
/
2
,
center
+
textsize
/
2
);
gui
::
IGUIStaticText
*
gui_loadingtext
=
guienv
->
addStaticText
(
loadingtext
,
textrect
,
false
,
false
);
gui_loadingtext
->
setTextAlignment
(
gui
::
EGUIA_CENTER
,
gui
::
EGUIA_UPPERLEFT
);
driver
->
beginScene
(
true
,
true
,
video
::
SColor
(
255
,
0
,
0
,
0
));
guienv
->
drawAll
();
driver
->
endScene
();
/*gui::IGUIStaticText *gui_loadingtext = */
//draw_load_screen(L"Loading and connecting...", driver, font);
draw_load_screen
(
L"Loading..."
,
driver
,
font
);
/*
Create server.
...
...
@@ -695,6 +716,7 @@ void the_game(
*/
SharedPtr
<
Server
>
server
;
if
(
address
==
""
){
draw_load_screen
(
L"Creating server..."
,
driver
,
font
);
std
::
cout
<<
DTIME
<<
"Creating server"
<<
std
::
endl
;
server
=
new
Server
(
map_dir
);
server
->
start
(
port
);
...
...
@@ -704,9 +726,11 @@ void the_game(
Create client
*/
draw_load_screen
(
L"Creating client..."
,
driver
,
font
);
std
::
cout
<<
DTIME
<<
"Creating client"
<<
std
::
endl
;
Client
client
(
device
,
playername
.
c_str
(),
password
,
draw_control
);
draw_load_screen
(
L"Resolving address..."
,
driver
,
font
);
Address
connect_address
(
0
,
0
,
0
,
0
,
port
);
try
{
if
(
address
==
""
)
...
...
@@ -720,7 +744,7 @@ void the_game(
std
::
cout
<<
DTIME
<<
"Couldn't resolve address"
<<
std
::
endl
;
//return 0;
error_message
=
L"Couldn't resolve address"
;
gui_loadingtext
->
remove
();
//
gui_loadingtext->remove();
return
;
}
...
...
@@ -753,11 +777,17 @@ void the_game(
{
break
;
}
std
::
wostringstream
ss
;
ss
<<
L"Connecting to server... (timeout in "
;
ss
<<
(
int
)(
10.0
-
time_counter
+
1.0
);
ss
<<
L" seconds)"
;
draw_load_screen
(
ss
.
str
(),
driver
,
font
);
// Update screen
/*
// Update screen
driver->beginScene(true, true, video::SColor(255,0,0,0));
guienv->drawAll();
driver
->
endScene
();
driver->endScene();
*/
// Update client and server
...
...
@@ -787,7 +817,7 @@ void the_game(
error_message
=
L"Connection timed out."
;
std
::
cout
<<
DTIME
<<
"Timed out."
<<
std
::
endl
;
}
gui_loadingtext
->
remove
();
//
gui_loadingtext->remove();
return
;
}
...
...
@@ -849,7 +879,7 @@ void the_game(
Move into game
*/
gui_loadingtext
->
remove
();
//
gui_loadingtext->remove();
/*
Add some gui stuff
...
...
@@ -2254,15 +2284,12 @@ void the_game(
generator and other stuff quits
*/
{
const
wchar_t
*
shuttingdowntext
=
L"Shutting down stuff..."
;
gui
::
IGUIStaticText
*
gui_shuttingdowntext
=
guienv
->
addStaticText
(
shuttingdowntext
,
textrect
,
false
,
false
);
gui_shuttingdowntext
->
setTextAlignment
(
gui
::
EGUIA_CENTER
,
gui
::
EGUIA_UPPERLEFT
);
driver
->
beginScene
(
true
,
true
,
video
::
SColor
(
255
,
0
,
0
,
0
));
/*gui::IGUIStaticText *gui_shuttingdowntext = */
draw_load_screen
(
L"Shutting down stuff..."
,
driver
,
font
);
/*driver->beginScene(true, true, video::SColor(255,0,0,0));
guienv->drawAll();
driver->endScene();
gui_shuttingdowntext
->
remove
();
gui_shuttingdowntext->remove();
*/
}
}
...
...
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