1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-19 08:52:33 +02:00

Implement text opcodes

This commit is contained in:
Daniel Evans 2016-07-12 00:08:10 +01:00 committed by dan
parent 6f8364a9e8
commit 0dd292ba28
2 changed files with 35 additions and 33 deletions

View File

@ -65,7 +65,7 @@ inline ScriptVec3 getGround(const ScriptArguments& args, ScriptVec3 p)
return p; return p;
} }
inline std::string gxt(const ScriptArguments& args, const ScriptString id) inline GameString gxt(const ScriptArguments& args, const ScriptString id)
{ {
return args.getWorld()->data->texts.text(id); return args.getWorld()->data->texts.text(id);
} }

View File

@ -2140,14 +2140,14 @@ bool opcode_00b1(const ScriptArguments& args, const ScriptVehicle vehicle, Scrip
opcode 00ba opcode 00ba
@arg gxtEntry GXT entry @arg gxtEntry GXT entry
@arg time Time (ms) @arg time Time (ms)
@arg arg3 @arg style
*/ */
void opcode_00ba(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt arg3) { void opcode_00ba(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt style) {
RW_UNIMPLEMENTED_OPCODE(0x00ba); const auto& text = script::gxt(args, gxtEntry);
RW_UNUSED(gxtEntry); args.getWorld()->state->text.addText<ScreenTextType::Big>(
RW_UNUSED(time); ScreenTextEntry::makeBig(
RW_UNUSED(arg3); gxtEntry, text, style, time
RW_UNUSED(args); ));
} }
/** /**
@ -2156,14 +2156,15 @@ void opcode_00ba(const ScriptArguments& args, const ScriptString gxtEntry, const
opcode 00bb opcode 00bb
@arg gxtEntry GXT entry @arg gxtEntry GXT entry
@arg time Time (ms) @arg time Time (ms)
@arg arg3 @arg flags
*/ */
void opcode_00bb(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt arg3) { void opcode_00bb(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt flags) {
RW_UNIMPLEMENTED_OPCODE(0x00bb); const auto& text = script::gxt(args, gxtEntry);
RW_UNUSED(gxtEntry); RW_UNUSED(flags);
RW_UNUSED(time); args.getWorld()->state->text.addText<ScreenTextType::HighPriority>(
RW_UNUSED(arg3); ScreenTextEntry::makeHighPriority(
RW_UNUSED(args); gxtEntry, text, time
));
} }
/** /**
@ -2175,27 +2176,28 @@ void opcode_00bb(const ScriptArguments& args, const ScriptString gxtEntry, const
@arg arg3 @arg arg3
*/ */
void opcode_00bc(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt arg3) { void opcode_00bc(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt arg3) {
RW_UNIMPLEMENTED_OPCODE(0x00bc); const auto& text = script::gxt(args, gxtEntry);
RW_UNUSED(gxtEntry);
RW_UNUSED(time);
RW_UNUSED(arg3); RW_UNUSED(arg3);
RW_UNUSED(args); RW_UNIMPLEMENTED("Unclear what style should be used");
args.getWorld()->state->text.addText<ScreenTextType::HighPriority>(
ScreenTextEntry::makeHighPriority(
gxtEntry, text, time
));
} }
/** /**
@brief print_soon %1g% duration %2d% ms flag %3d% @brief print_soon %1g% duration %2d% ms flag %3d%
opcode 00bd opcode 00bd
@arg arg1 @arg gxtEntry
@arg arg2 @arg time
@arg arg3 @arg arg3
*/ */
void opcode_00bd(const ScriptArguments& args, const ScriptString arg1, const ScriptInt arg2, const ScriptInt arg3) { void opcode_00bd(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt time, const ScriptInt arg3) {
RW_UNIMPLEMENTED_OPCODE(0x00bd); const auto& text = script::gxt(args, gxtEntry);
RW_UNUSED(arg1);
RW_UNUSED(arg2);
RW_UNUSED(arg3); RW_UNUSED(arg3);
RW_UNUSED(args); args.getWorld()->state->text.addText<ScreenTextType::BigLowPriority>(
ScreenTextEntry::makeBig(gxtEntry, text, arg3, time));
} }
/** /**
@ -2204,8 +2206,7 @@ void opcode_00bd(const ScriptArguments& args, const ScriptString arg1, const Scr
opcode 00be opcode 00be
*/ */
void opcode_00be(const ScriptArguments& args) { void opcode_00be(const ScriptArguments& args) {
RW_UNIMPLEMENTED_OPCODE(0x00be); args.getWorld()->state->text.clear<ScreenTextType::Big>();
RW_UNUSED(args);
} }
/** /**
@ -5857,10 +5858,10 @@ void opcode_01e2(const ScriptArguments& args, const ScriptInt arg1, const Script
@arg style @arg style
*/ */
void opcode_01e3(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt arg2, const ScriptInt time, const ScriptInt style) { void opcode_01e3(const ScriptArguments& args, const ScriptString gxtEntry, const ScriptInt arg2, const ScriptInt time, const ScriptInt style) {
std::string str = auto str =
ScreenText::format( ScreenText::format(
script::gxt(args, gxtEntry), script::gxt(args, gxtEntry),
std::to_string(arg2)); GameStringUtil::fromString(std::to_string(arg2)));
args.getState()->text.addText<ScreenTextType::Big>( args.getState()->text.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig(
gxtEntry, str, style, time gxtEntry, str, style, time
@ -10305,9 +10306,10 @@ void opcode_036d(const ScriptArguments& args, const ScriptString gxtEntry, const
unsigned short style = args[4].integerValue(); unsigned short style = args[4].integerValue();
std::string str = auto str =
ScreenText::format(script::gxt(args, gxtEntry), std::to_string(arg2), ScreenText::format(script::gxt(args, gxtEntry),
std::to_string(arg3)); GameStringUtil::fromString(std::to_string(arg2)),
GameStringUtil::fromString(std::to_string(arg3)));
auto textEntry = ScreenTextEntry::makeBig(gxtEntry, str, style, time); auto textEntry = ScreenTextEntry::makeBig(gxtEntry, str, style, time);
world->state->text.addText<ScreenTextType::Big>(textEntry); world->state->text.addText<ScreenTextType::Big>(textEntry);