-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
834 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ SET( SRC ${SRC} | |
${PWD}/Player.cpp | ||
${PWD}/Slot.cpp | ||
${PWD}/Slots.cpp | ||
${PWD}/Event.cpp | ||
|
||
PARENT_SCOPE ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "Event.h" | ||
|
||
#include <cstring> | ||
|
||
#include "base/Base.h" | ||
|
||
namespace game { | ||
|
||
Event::Event( const Event::event_type_t type ) | ||
: type( type ) { | ||
memset( &data, 0, sizeof( data ) ); | ||
} | ||
|
||
Event::Event( const Event& other ) | ||
: type( other.type ) { | ||
switch ( type ) { | ||
case ET_QUIT: { | ||
NEW( data.quit.reason, std::string, *other.data.quit.reason ); | ||
break; | ||
} | ||
case ET_GLOBAL_MESSAGE: { | ||
NEW( data.global_message.message, std::string, *other.data.global_message.message ); | ||
break; | ||
} | ||
default: { | ||
// | ||
} | ||
} | ||
} | ||
|
||
Event::~Event() { | ||
switch ( type ) { | ||
case ET_QUIT: { | ||
if ( data.quit.reason ) { | ||
DELETE( data.quit.reason ); | ||
} | ||
break; | ||
} | ||
case ET_GLOBAL_MESSAGE: { | ||
if ( data.global_message.message ) { | ||
DELETE( data.global_message.message ); | ||
} | ||
break; | ||
} | ||
default: { | ||
// | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
namespace game { | ||
|
||
class Event { | ||
public: | ||
|
||
enum event_type_t { | ||
ET_NONE, | ||
ET_QUIT, | ||
ET_GLOBAL_MESSAGE, | ||
}; | ||
Event( const event_type_t type ); | ||
Event( const Event& other ); | ||
virtual ~Event(); | ||
|
||
const event_type_t type = ET_NONE; | ||
|
||
union { | ||
struct { | ||
std::string* reason; | ||
} quit; | ||
struct { | ||
std::string* message; | ||
} global_message; | ||
} data; | ||
}; | ||
|
||
typedef std::vector< Event > game_events_t; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.