mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
Improve game text behaviour
* Fix messages not being cleared * Implemented clearing help messages
This commit is contained in:
parent
c7376273b4
commit
66b7c878c1
@ -143,9 +143,15 @@ struct GameState
|
|||||||
std::map<unsigned short, std::string> specialCharacters;
|
std::map<unsigned short, std::string> specialCharacters;
|
||||||
std::map<unsigned short, std::string> specialModels;
|
std::map<unsigned short, std::string> specialModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores long-lasting on screen messages
|
||||||
|
*/
|
||||||
std::vector<OnscreenText> text;
|
std::vector<OnscreenText> text;
|
||||||
|
|
||||||
TextDisplayData nextText;
|
TextDisplayData nextText;
|
||||||
|
/**
|
||||||
|
* Stores temporary, one-tick messages
|
||||||
|
*/
|
||||||
std::vector<TextDisplayData> texts;
|
std::vector<TextDisplayData> texts;
|
||||||
|
|
||||||
/** The camera near value currently set by the script */
|
/** The camera near value currently set by the script */
|
||||||
|
@ -771,7 +771,7 @@ void game_play_music_id(const ScriptArguments& args)
|
|||||||
void game_clear_print(const ScriptArguments& args)
|
void game_clear_print(const ScriptArguments& args)
|
||||||
{
|
{
|
||||||
std::string id(args[0].string);
|
std::string id(args[0].string);
|
||||||
|
|
||||||
for( int i = 0; i < args.getVM()->getWorld()->state.text.size(); )
|
for( int i = 0; i < args.getVM()->getWorld()->state.text.size(); )
|
||||||
{
|
{
|
||||||
if( args.getVM()->getWorld()->state.text[i].id == id )
|
if( args.getVM()->getWorld()->state.text[i].id == id )
|
||||||
@ -794,7 +794,7 @@ void game_display_help(const ScriptArguments& args)
|
|||||||
{
|
{
|
||||||
std::string id(args[0].string);
|
std::string id(args[0].string);
|
||||||
std::string str = args.getVM()->getWorld()->gameData.texts.text(id);
|
std::string str = args.getVM()->getWorld()->gameData.texts.text(id);
|
||||||
unsigned short style = 12;
|
unsigned short style = OnscreenText::Help;
|
||||||
args.getVM()->getWorld()->state.text.push_back({
|
args.getVM()->getWorld()->state.text.push_back({
|
||||||
id,
|
id,
|
||||||
str,
|
str,
|
||||||
@ -804,6 +804,18 @@ void game_display_help(const ScriptArguments& args)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void game_clear_help(const ScriptArguments& args)
|
||||||
|
{
|
||||||
|
for( int i = 0; i < args.getVM()->getWorld()->state.text.size(); )
|
||||||
|
{
|
||||||
|
auto& texts = args.getVM()->getWorld()->state.text;
|
||||||
|
if( texts[i].osTextStyle == OnscreenText::Help )
|
||||||
|
{
|
||||||
|
texts.erase(texts.begin() + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool game_can_player_move(const ScriptArguments& args)
|
bool game_can_player_move(const ScriptArguments& args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -1089,7 +1101,7 @@ GameModule::GameModule()
|
|||||||
bindFunction(0x03E1, game_get_found_hidden_packages, 1, "Get Hidden Packages Found" );
|
bindFunction(0x03E1, game_get_found_hidden_packages, 1, "Get Hidden Packages Found" );
|
||||||
|
|
||||||
bindFunction(0x03E5, game_display_help, 1, "Display Help Text" );
|
bindFunction(0x03E5, game_display_help, 1, "Display Help Text" );
|
||||||
bindUnimplemented( 0x03E6, game_clear_help, 0, "Clear Help Text" );
|
bindFunction(0x03E6, game_clear_help, 0, "Clear Help Text" );
|
||||||
bindUnimplemented( 0x03E7, game_flash_hud, 1, "Flash HUD Item" );
|
bindUnimplemented( 0x03E7, game_flash_hud, 1, "Flash HUD Item" );
|
||||||
|
|
||||||
bindUnimplemented( 0x03EB, game_clear_prints, 0, "Clear Small Prints" );
|
bindUnimplemented( 0x03EB, game_clear_prints, 0, "Clear Small Prints" );
|
||||||
|
@ -304,6 +304,19 @@ void RWGame::tick(float dt)
|
|||||||
engine->destroyQueuedObjects();
|
engine->destroyQueuedObjects();
|
||||||
engine->state.texts.clear();
|
engine->state.texts.clear();
|
||||||
|
|
||||||
|
for( int i = 0; i < engine->state.text.size(); )
|
||||||
|
{
|
||||||
|
auto& text = engine->state.text[i];
|
||||||
|
if( engine->gameTime > text.osTextStart + text.osTextTime )
|
||||||
|
{
|
||||||
|
engine->state.text.erase(engine->state.text.begin() + i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
engine->dynamicsWorld->stepSimulation(dt, 2, dt);
|
engine->dynamicsWorld->stepSimulation(dt, 2, dt);
|
||||||
|
|
||||||
if( script ) {
|
if( script ) {
|
||||||
@ -496,19 +509,6 @@ void RWGame::renderDebugStats(float time)
|
|||||||
engine->renderer.text.renderText(ti);
|
engine->renderer.text.renderText(ti);
|
||||||
ti.screenPosition.y -= ti.size;
|
ti.screenPosition.y -= ti.size;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for( int i = 0; i < engine->state.text.size(); )
|
|
||||||
{
|
|
||||||
if( engine->gameTime > engine->state.text[i].osTextStart + engine->state.text[i].osTextTime )
|
|
||||||
{
|
|
||||||
engine->state.text.erase(engine->state.text.begin() + i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RWGame::globalKeyEvent(const sf::Event& event)
|
void RWGame::globalKeyEvent(const sf::Event& event)
|
||||||
|
Loading…
Reference in New Issue
Block a user