Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Печенин Данила Михайлович
Pacman
Commits
dd3848e9
Commit
dd3848e9
authored
3 weeks ago
by
Печенин Данила Михайлович
Browse files
Options
Download
Patches
Plain Diff
ContextManager was done
parent
bdc77b95
main
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
source/States/GameState/ContextManager.cpp
+19
-0
source/States/GameState/ContextManager.cpp
source/States/GameState/ContextManager.h
+14
-0
source/States/GameState/ContextManager.h
source/States/GameState/GameState.cpp
+1
-1
source/States/GameState/GameState.cpp
source/States/GameState/GameState.h
+12
-2
source/States/GameState/GameState.h
source/States/GameState/Maze/Maze.h
+1
-0
source/States/GameState/Maze/Maze.h
source/States/SelectState/SelectState.h
+1
-0
source/States/SelectState/SelectState.h
with
48 additions
and
3 deletions
+48
-3
source/States/GameState/ContextManager.cpp
0 → 100644
+
19
−
0
View file @
dd3848e9
#include
<States/GameState/ContextManager.h>
void
ContextManager
::
reset
(
GameContext
&&
context
)
{
while
(
!
m_contexts
.
empty
())
m_contexts
.
pop
();
m_initial_context
=
std
::
move
(
context
);
m_contexts
.
emplace
(
m_initial_context
.
clone
());
}
void
ContextManager
::
save_context
()
{
m_contexts
.
emplace
(
m_contexts
.
top
().
clone
());
}
void
ContextManager
::
restore_previous_context
()
{
if
(
m_contexts
.
size
()
>
1
)
m_contexts
.
pop
();
else
m_contexts
.
top
()
=
m_initial_context
.
clone
();
}
This diff is collapsed.
Click to expand it.
source/States/GameState/ContextManager.h
0 → 100644
+
14
−
0
View file @
dd3848e9
#pragma once
#include
<States/GameState/GameContext.h>
#include
<stack>
class
ContextManager
{
public:
void
reset
(
GameContext
&&
context
);
GameContext
&
get_current_context
()
{
return
m_contexts
.
top
();
}
void
save_context
();
void
restore_previous_context
();
private
:
GameContext
m_initial_context
;
std
::
stack
<
GameContext
>
m_contexts
;
};
This diff is collapsed.
Click to expand it.
source/States/GameState/GameState.cpp
+
1
−
1
View file @
dd3848e9
#include
"
GameState.h
"
#include
<States/GameState/
GameState.h
>
#include
<iostream>
/// @todo remove it
#include
<States/ExitState/ExitState.h>
...
...
This diff is collapsed.
Click to expand it.
source/States/GameState/GameState.h
+
12
−
2
View file @
dd3848e9
#pragma once
#include
<BasicAbstractions/IState.h>
#include
<BasicAbstractions/IWindowKeeper.h>
#include
<States/GameState/Maze/Maze.h>
#include
<States/GameState/ContextManager.h>
struct
GameState
:
IState
,
IWindowKeeper
{
explicit
GameState
(
IStateManager
&
state_manager
,
const
sf
::
VideoMode
&
video_mode
,
const
sf
::
String
&
window_title
)
:
IState
(
state_manager
),
IWindowKeeper
(
video_mode
,
window_title
)
{}
class
GameState
:
IState
,
IWindowKeeper
{
public:
explicit
GameState
(
IStateManager
&
state_manager
,
const
sf
::
VideoMode
&
video_mode
,
const
sf
::
String
&
window_title
)
:
IState
(
state_manager
),
IWindowKeeper
(
video_mode
,
window_title
)
{}
bool
do_step
()
override
;
void
set_maze
(
Maze
&&
maze
)
{
m_maze
=
std
::
move
(
maze
);
}
void
set_context
(
GameContext
&&
context
)
{
m_context_manager
.
reset
(
std
::
move
(
context
));
}
private
:
void
event_handling
()
override
{};
void
update
()
override
{};
void
render
()
override
{};
private
:
Maze
m_maze
;
ContextManager
m_context_manager
;
};
This diff is collapsed.
Click to expand it.
source/States/GameState/Maze/Maze.h
+
1
−
0
View file @
dd3848e9
...
...
@@ -6,6 +6,7 @@
class
Maze
:
public
IDrawable
{
public:
Maze
()
=
default
;
explicit
Maze
(
std
::
vector
<
std
::
unique_ptr
<
Room
>>
rooms
)
:
m_rooms
(
std
::
move
(
rooms
))
{}
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
private
:
...
...
This diff is collapsed.
Click to expand it.
source/States/SelectState/SelectState.h
+
1
−
0
View file @
dd3848e9
...
...
@@ -33,6 +33,7 @@ public:
explicit
SelectState
(
IStateManager
&
state_manager
,
const
sf
::
VideoMode
&
video_mode
,
const
sf
::
String
&
window_title
)
:
IState
(
state_manager
),
IWindowKeeper
(
video_mode
,
window_title
),
m_menu
(
state_manager
)
{}
bool
do_step
()
override
;
private
:
void
event_handling
()
override
;
void
update
()
override
;
void
render
()
override
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets