Skip to content

Commit

Permalink
Extract localization data from SCR files
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-ushakov committed Jan 6, 2025
1 parent dd65ee7 commit 095fec8
Show file tree
Hide file tree
Showing 30 changed files with 23,516 additions and 501 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ project(MOONSHINE_RUNNERS VERSION 1.0.0 LANGUAGES C CXX)

set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")

option(BUILD_SCRIPT_TOOL "Build script tool" OFF)

set(APPLICATION_NAME moonshine-runners)

if (UNIX AND NOT APPLE)
Expand Down Expand Up @@ -41,6 +43,10 @@ add_subdirectory(3rdparty/musepack_src_r475)

add_subdirectory(MechoSoma)

if(BUILD_SCRIPT_TOOL)
add_subdirectory(ScriptTool)
endif(BUILD_SCRIPT_TOOL)

set_target_properties(${APPLICATION_NAME} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
Expand Down
9 changes: 6 additions & 3 deletions MechoSoma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
endif()

set(GAME_SOURCES
# aciparser
aciparser/aci_parser.cpp
# ParserC
ParserC/math_exp.cpp
ParserC/prepare.cpp
ParserC/script_err.cpp
ParserC/script.cpp
# FX
FX/Hermit.h
FX/XTList.h
Expand Down Expand Up @@ -476,14 +479,14 @@ set(GAME_SOURCES
app/texture_manager.h
)

include_directories(aciparser)
include_directories(app)
include_directories(FX)
include_directories(IVisGeneric)
include_directories(Sound)
include_directories(Terra)
include_directories(RUNTIME)
include_directories(RUNTIME/Scripts)
include_directories(ParserC)
include_directories(VisGeneric)
include_directories(VisGeneric/md3d)
include_directories(VisGeneric/Graph3d)
Expand Down
31 changes: 31 additions & 0 deletions MechoSoma/ParserC/aci_define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

#ifndef __ACI_DEFINE_H__
#define __ACI_DEFINE_H__

// scrDefineData::flags
const unsigned DEF_TEXT = 0x01;

struct scrDefineData
{
int flags;

int startIndex;
int endIndex;

int srcLen;
char* srcData;

int destLen;
char* destData;

void* list;
scrDefineData* prev;
scrDefineData* next;

void init(char* ptr,int sz);

scrDefineData(void);
~scrDefineData(void);
};

#endif /* __ACI_DEFINE_H__ */
174 changes: 89 additions & 85 deletions MechoSoma/aciparser/aci_parser.h → MechoSoma/ParserC/aci_parser.h
Original file line number Diff line number Diff line change
@@ -1,85 +1,89 @@

#ifndef __ACI_PARSER_H__
#define __ACI_PARSER_H__

#include <filesystem>
#include <string>

#include "xtool.h"

// scrDataBlock flags...
#define SCR_ALLOC_DATA 0x01

// Data types...
enum scrDataTypes {
SCR_VOID_DATA = 0,
SCR_INT_DATA,
SCR_DOUBLE_DATA,
SCR_CHAR_DATA,

SCR_MAX_DATA_ID
};

struct scrDataBlock
{
int ID;
int flags;
int dataSize;
int dataType;

int dataSize0;
char* name;

union {
int* i_dataPtr;
double* d_dataPtr;
char* c_dataPtr;
};

scrDataBlock* owner;
xtList<scrDataBlock>* nextLevel;

void* list;
scrDataBlock* prev;
scrDataBlock* next;

void saveInfo(XStream& fh);
void saveData(XStream& fh);
void loadInfo(XStream& fh);
void loadData(XStream& fh);

void loadInfo(XBuffer& fh);
void loadData(XBuffer& fh);

void initName(char* p);
void allocList(void){ nextLevel = new xtList<scrDataBlock>; }

void alloc(int tp,int sz);
void allocData(void);
void freeData(void);

void add(scrDataBlock* p);
void dump(XStream& fh,int idx,int mode = 0);
void get_keys(void);

scrDataBlock* find(int id){ if(nextLevel) return nextLevel -> search(id); return NULL; }

scrDataBlock(int tp);
scrDataBlock(void);
~scrDataBlock(void);
};

void scrSetVerbose(int v = 1);

void scrSetInputDir(const char* p);
void scrSetOutputDir(const char* p);
void scrSetOutputFile(const char* p);

scrDataBlock* loadScript(const std::string &path);
scrDataBlock* loadScript(XStream& fh);
scrDataBlock* parseScript(const char* fname,const char *set_name);
void saveScript(const char* fname,scrDataBlock* p);
void dumpScript(const char* fname,scrDataBlock* p);
void dumpScriptKeywords(const char* fname,scrDataBlock* p);

#endif /* __ACI_PARSER_H__ */

#ifndef __ACI_PARSER_H__
#define __ACI_PARSER_H__

#include <filesystem>
#include <functional>
#include <string>
#include <string_view>

#include "xtool.h"

// scrDataBlock flags...
#define SCR_ALLOC_DATA 0x01

// Data types...
enum scrDataTypes {
SCR_VOID_DATA = 0,
SCR_INT_DATA,
SCR_DOUBLE_DATA,
SCR_CHAR_DATA,

SCR_MAX_DATA_ID
};

struct scrDataBlock
{
int ID;
int flags;
int dataSize;
int dataType;

int dataSize0;
char* name;

union {
int* i_dataPtr;
double* d_dataPtr;
char* c_dataPtr;
};

scrDataBlock* owner;
xtList<scrDataBlock>* nextLevel;

void* list;
scrDataBlock* prev;
scrDataBlock* next;

void saveInfo(XStream& fh);
void saveData(XStream& fh);
void loadInfo(XStream& fh);
void loadData(XStream& fh);

void loadInfo(XBuffer& fh);
void loadData(XBuffer& fh);

void initName(const char* p);
void allocList(void){ nextLevel = new xtList<scrDataBlock>; }

void alloc(int tp,int sz);
void allocData(void);
void freeData(void);

void add(scrDataBlock* p);
void dump(XStream& fh,int idx,int mode = 0);
void get_keys(void);

scrDataBlock* find(int id){ if(nextLevel) return nextLevel -> search(id); return NULL; }

scrDataBlock(int tp);
scrDataBlock(void);
~scrDataBlock(void);
};

void scrSetVerbose(int v = 1);

void scrSetInputDir(const char* p);
void scrSetOutputDir(const char* p);
void scrSetOutputFile(const char* p);

scrDataBlock* loadScript(const std::string &fname);
scrDataBlock* loadScript(XStream& fh);
scrDataBlock* parseScript(const char* fname,const char *set_name);
void saveScript(const char* fname,scrDataBlock* p);
void dumpScript(const char* fname,scrDataBlock* p);
void dumpScriptKeywords(const char* fname,scrDataBlock* p);

extern std::function<const std::string_view (const std::string_view)> getLocalizedKey;

#endif /* __ACI_PARSER_H__ */
Loading

0 comments on commit 095fec8

Please sign in to comment.