Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(devilutionx_assets
txtdata/quests/questdat.tsv
txtdata/sound/effects.tsv
txtdata/spells/spelldat.tsv
txtdata/text/textdat.tsv
ui_art/diablo.pal
ui_art/creditsw.clx
ui_art/dvl_but_sml.clx
Expand Down
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ else()
DevilutionX::SDL
SDL_audiolib::SDL_audiolib
fmt::fmt
magic_enum::magic_enum
tl
unordered_dense::unordered_dense
libdevilutionx_options
Expand Down
2 changes: 2 additions & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@

// Controller support: Actions to run after updating the cursor state.
// Defined in SourceX/controls/plctrls.cpp.
extern void plrctrls_after_check_curs_move();

Check warning on line 146 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:146:13 [readability-redundant-declaration]

redundant 'plrctrls_after_check_curs_move' declaration
extern void plrctrls_every_frame();

Check warning on line 147 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:147:13 [readability-redundant-declaration]

redundant 'plrctrls_every_frame' declaration
extern void plrctrls_after_game_logic();

Check warning on line 148 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:148:13 [readability-redundant-declaration]

redundant 'plrctrls_after_game_logic' declaration

namespace {

Expand Down Expand Up @@ -230,7 +230,7 @@
return true;
}

void LeftMouseCmd(bool bShift)

Check warning on line 233 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:233:6 [readability-function-cognitive-complexity]

function 'LeftMouseCmd' has cognitive complexity of 50 (threshold 25)
{
bool bNear;

Expand Down Expand Up @@ -316,7 +316,7 @@
return true;
}

void LeftMouseDown(uint16_t modState)

Check warning on line 319 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:319:6 [readability-function-cognitive-complexity]

function 'LeftMouseDown' has cognitive complexity of 55 (threshold 25)
{
LastPlayerAction = PlayerActionType::None;

Expand Down Expand Up @@ -479,7 +479,7 @@
QuestLogIsOpen = false;
}

void PressKey(SDL_Keycode vkey, uint16_t modState)

Check warning on line 482 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:482:6 [readability-function-cognitive-complexity]

function 'PressKey' has cognitive complexity of 85 (threshold 25)
{
Options &options = GetOptions();
remap_keyboard_key(&vkey);
Expand Down Expand Up @@ -712,7 +712,7 @@
}
}

void GameEventHandler(const SDL_Event &event, uint16_t modState)

Check warning on line 715 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:715:6 [readability-function-cognitive-complexity]

function 'GameEventHandler' has cognitive complexity of 69 (threshold 25)
{
[[maybe_unused]] const Options &options = GetOptions();
StaticVector<ControllerButtonEvent, 4> ctrlEvents = ToControllerButtonEvents(event);
Expand All @@ -733,7 +733,7 @@
}
}
}
if (ctrlEvents.size() > 0 && ctrlEvents[0].button != ControllerButton_NONE) {

Check warning on line 736 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:736:6 [readability-container-size-empty]

the 'empty' method should be used to check for emptiness instead of 'size'
return;
}

Expand Down Expand Up @@ -787,12 +787,12 @@
ChatLogScrollUp();
} else if (IsStashOpen) {
Stash.PreviousPage();
} else if (SDL_GetModState() & KMOD_CTRL) {

Check warning on line 790 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:790:15 [readability-implicit-bool-conversion]

implicit conversion 'int' -> bool
if (AutomapActive) {
AutomapZoomIn();
}
} else {
KeymapperPress(MouseScrollUpButton);

Check warning on line 795 in Source/diablo.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/diablo.cpp:795:20 [bugprone-narrowing-conversions]

narrowing conversion from constant value 2147549184 (0x80010000) of type 'uint32_t' (aka 'unsigned int') to signed type 'SDL_Keycode' (aka 'int') is implementation-defined
}
} else if (event.wheel.y < 0) { // down
if (IsPlayerInStore()) {
Expand Down Expand Up @@ -2666,6 +2666,8 @@
// Finally load game data
LoadGameArchives();

LoadTextData();

// Load dynamic data before we go into the menu as we need to initialise player characters in memory pretty early.
LoadPlayerDataFiles();

Expand Down
16 changes: 16 additions & 0 deletions Source/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string_view>

#include <expected.hpp>
#include <magic_enum/magic_enum.hpp>

#include "data/file.hpp"
#include "data/iterators.hpp"
Expand All @@ -21,6 +22,12 @@
#include "player.h"
#include "utils/is_of.hpp"

template <>
struct magic_enum::customize::enum_range<devilution::SfxID> {
static constexpr int min = static_cast<int>(devilution::SfxID::None);
static constexpr int max = static_cast<int>(devilution::SfxID::LAST);
};

namespace devilution {

int sfxdelay;
Expand Down Expand Up @@ -310,4 +317,13 @@ int GetSFXLength(SfxID nSFX)
return sfx.pSnd->DSB.GetLength();
}

tl::expected<SfxID, std::string> ParseSfxId(std::string_view value)
{
const std::optional<SfxID> enumValueOpt = magic_enum::enum_cast<SfxID>(value);
if (enumValueOpt.has_value()) {
return enumValueOpt.value();
}
return tl::make_unexpected("Unknown enum value.");
}

} // namespace devilution
4 changes: 4 additions & 0 deletions Source/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <memory>
#include <string>

#include <expected.hpp>

#include "engine/sound.h"
#include "sound_effect_enums.h"

Expand All @@ -35,4 +37,6 @@ void ui_sound_init();
void effects_play_sound(SfxID);
int GetSFXLength(SfxID nSFX);

tl::expected<SfxID, std::string> ParseSfxId(std::string_view value);

} // namespace devilution
1 change: 1 addition & 0 deletions Source/lua/lua_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ void LuaReloadActiveMods()
}

// Reload game data (this can probably be done later in the process to avoid having to reload it)
LoadTextData();
LoadPlayerDataFiles();
LoadSpellData();
LoadMissileData();
Expand Down
2 changes: 1 addition & 1 deletion Source/quests/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool IsQuestDeltaValid(quest_id qidx, quest_state qstate, uint8_t qlog, int16_t
if (IsNoneOf(qlog, 0, 1))
return false;

if (qmsg < 0 || static_cast<size_t>(qmsg) >= SpeechCount)
if (qmsg < 0 || static_cast<size_t>(qmsg) >= Speeches.size())
return false;

switch (qstate) {
Expand Down
992 changes: 85 additions & 907 deletions Source/textdat.cpp

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Source/textdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ enum _speech_id : int16_t {
TEXT_BBOOKA,
TEXT_BBOOKB,
TEXT_BBOOKC,
/*
TEXT_DEADGUY,
TEXT_FARNHAM14,
TEXT_FARNHAM15,
Expand Down Expand Up @@ -424,20 +423,20 @@ enum _speech_id : int16_t {
TEXT_GRISWOLD35,
TEXT_GRISWOLD36,
TEXT_GRISWOLD37,
*/
NUM_TEXT_IDS,
NUM_DEFAULT_TEXT_IDS,
TEXT_NONE = -1,
};

struct Speech {
const char *txtstr;
std::string txtstr;
bool scrlltxt;
SfxID sfxnr;
};

extern const size_t SpeechCount;
extern const Speech Speeches[];
extern std::vector<Speech> Speeches;

tl::expected<_speech_id, std::string> ParseSpeechId(std::string_view value);

void LoadTextData();

} // namespace devilution
140 changes: 140 additions & 0 deletions assets/txtdata/text/textdat-unused.tsv

Large diffs are not rendered by default.

339 changes: 339 additions & 0 deletions assets/txtdata/text/textdat.tsv

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tools/extract_translation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"item_suffixes": root.joinpath("assets/txtdata/items/item_suffixes.tsv"),
"questdat": root.joinpath("assets/txtdata/quests/questdat.tsv"),
"spelldat": root.joinpath("assets/txtdata/spells/spelldat.tsv"),
"textdat": root.joinpath("assets/txtdata/text/textdat.tsv"),
}

hf_paths = {
Expand Down Expand Up @@ -97,6 +98,13 @@ def process_files(paths, temp_source):
var_name = 'SPELL_' + row['name'].upper().replace(' ', '_').replace('-', '_')
write_entry(temp_source, f'{var_name}_NAME', "spell", row['name'], True)

# Text/Speeches
if "textdat" in paths:
with open(paths["textdat"], 'r') as tsv:
reader = csv.DictReader(tsv, delimiter='\t')
for i, row in enumerate(reader):
write_entry(temp_source, f'TEXT_{i}', "default", row['txtstr'], False)

with open(translation_dummy_path, 'w') as temp_source:
temp_source.write(f'/**\n')
temp_source.write(f' * @file translation_dummy.cpp\n')
Expand Down
Loading