1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +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;
}
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);
}

View File

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