mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-08 15:40:28 -04:00
translation for shops, maps, titles
This commit is contained in:
parent
45bb0c8431
commit
f1f6cff78f
4 changed files with 59 additions and 5 deletions
|
@ -85,6 +85,35 @@ static char convert_map_strings(const char *target_path) {
|
|||
return !list_files(build_pathname(1, gpathtable[SR_MAP]), file_type_normal|file_type_just_name,convert_map_strings_1 , &target_path);
|
||||
}
|
||||
|
||||
typedef struct make_map_name_stringtable_ctx_tag{
|
||||
FILE *out;
|
||||
} make_map_name_stringtable_ctx;
|
||||
|
||||
static int make_map_name_stringtable_cb(const char *source_name, LIST_FILE_TYPE type, size_t sz, void *context) {
|
||||
make_map_name_stringtable_ctx *ctx = (make_map_name_stringtable_ctx *)context;
|
||||
if (istrcmp(source_name+strlen(source_name)-4,".map")) return 0;
|
||||
uint32_t id = fnv1a_hash(source_name);
|
||||
fprintf(ctx->out, "%u,%s\n", id, source_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char make_map_name_stringtable(const char *target_path) {
|
||||
const char *target_file = build_pathname(2,target_path,"mapnames.csv");
|
||||
target_file = local_strdup(target_file);
|
||||
FILE *f = fopen_icase(target_file, "w");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Failed to open %s for writing\n",target_file);
|
||||
return 0;
|
||||
}
|
||||
fprintf(f, "id,string\n");
|
||||
make_map_name_stringtable_ctx ctx;
|
||||
ctx.out = f;
|
||||
int ret = list_files(build_pathname(1, gpathtable[SR_MAP]), file_type_normal|file_type_just_name,make_map_name_stringtable_cb, &ctx);
|
||||
printf("Writing %s\n", target_file);
|
||||
fclose(f);
|
||||
return !ret;
|
||||
}
|
||||
|
||||
|
||||
static char convert_file_to(const char *src_file, const char *target_file) {
|
||||
TMPFILE_RD *rd = enc_open(src_file);
|
||||
|
@ -224,6 +253,7 @@ char generate_string_tables(const char *path) {
|
|||
if (!generate_dialog_table(path)) return 0;
|
||||
if (!convert_intro_titles(path)) return 0;
|
||||
if (!generate_shop_strings(path)) return 0;
|
||||
if (!make_map_name_stringtable(path)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
13
game/inv.c
13
game/inv.c
|
@ -82,7 +82,7 @@ static TSHOP_ALL_STATE shop_all_state;
|
|||
#define INV_YS 60
|
||||
#define INV_NAME_X 129
|
||||
#define INV_NAME_Y 349
|
||||
#define INV_NAME_COL (RGB555(10,31,31)|FONT_TSHADOW_GRAY)
|
||||
#define INV_NAME_COL (RGB555(10,31,31)|FONT_TSHADOW)
|
||||
#define INV_DESK 266
|
||||
#define INV_INFO_X 298
|
||||
#define INV_INFO_Y 343
|
||||
|
@ -2547,6 +2547,8 @@ static void rebuild_shops(const void *shop_ptr)
|
|||
const char *c=(const char *)shop_ptr;
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
SEND_LOG("(SHOP) Rebuilding shops....");
|
||||
max_shops = *(const int32_t *)c;
|
||||
c+=4;
|
||||
|
@ -2574,9 +2576,17 @@ static void rebuild_shops(const void *shop_ptr)
|
|||
shop_all_state.first_state = (TSHOP_PRODUCT_STATE *)(prod_iter+products);
|
||||
TSHOP_PRODUCT_STATE *state_iter = shop_all_state.first_state;
|
||||
|
||||
TSTRINGTABLE *stbl = lang_load("shops.dat");
|
||||
|
||||
for(i=0;i<max_shops;i++) {
|
||||
shop_list[i] = shop_iter;
|
||||
c = load_TSHOP(c, shop_iter);
|
||||
if (stbl) {
|
||||
const char *n = stringtable_find(stbl,shop_iter->shop_id,NULL);
|
||||
if (n) {
|
||||
strcopy_n(shop_iter->keeper,n,sizeof(shop_iter->keeper));
|
||||
}
|
||||
}
|
||||
shop_iter->list = prod_iter;
|
||||
for (int j = 0; j < shop_iter->products; ++j) {
|
||||
c = load_TPRODUCT(c, prod_iter);
|
||||
|
@ -2588,6 +2598,7 @@ static void rebuild_shops(const void *shop_ptr)
|
|||
++shop_iter;
|
||||
SEND_LOG("(SHOP) Shop found: '%s', products %d",shop_list[i]->keeper,shop_list[i]->products);
|
||||
}
|
||||
stringtable_free(stbl);
|
||||
free(shop_hacek);
|
||||
shop_hacek = newhacek;
|
||||
}
|
||||
|
|
|
@ -229,6 +229,17 @@ void sanitize_map() {
|
|||
|
||||
}
|
||||
|
||||
void translate_map_name(const char *mapfile, MAPGLOBAL *mglob) {
|
||||
uint32_t id = fnv1a_hash(mapfile);
|
||||
const TSTRINGTABLE *stable = lang_load("mapnames.csv");
|
||||
if (stable) {
|
||||
const char *rplc = stringtable_find(stable, id, NULL);
|
||||
if (rplc) {
|
||||
strcopy_n(mglob->mapname,rplc,sizeof(mglob->mapname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int load_map(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -316,12 +327,14 @@ int load_map(const char *filename)
|
|||
case A_MAPGLOB:
|
||||
num_ofsets[BACK_NUM]=ofsts;
|
||||
num_ofsets_count[BACK_NUM]=1;
|
||||
memset(&mglob,0,sizeof(mglob));
|
||||
memset(&mglob,0,sizeof(mglob));
|
||||
memcpy(&mglob,temp,MIN((int)size,(int)sizeof(mglob)));
|
||||
free(temp);
|
||||
for(r=0;r<4;r++)
|
||||
def_handle(ofsts++,mglob.back_fnames[r],pcx_fade_decomp,SR_GRAFIKA);
|
||||
for(r=0;r<4;r++) {
|
||||
def_handle(ofsts++,mglob.back_fnames[r],pcx_fade_decomp,SR_GRAFIKA);
|
||||
}
|
||||
back_color=RGB888(mglob.fade_r,mglob.fade_g,mglob.fade_b);
|
||||
translate_map_name(filename, &mglob);;
|
||||
break;
|
||||
case A_MAPITEM:
|
||||
SEND_LOG("(GAME) Loading items...");
|
||||
|
|
|
@ -129,7 +129,7 @@ static void PlayMGFFile(const void *file, MGIF_PROC proc,int ypos,char full)
|
|||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
mgif_install_proc(proc);
|
||||
sound=PrepareVideoSound(22050,256*1024);
|
||||
sound=PrepareVideoSound(22050,226*1024);
|
||||
picture=getmem(2*3+320*180*2);
|
||||
picture[0]=320;
|
||||
picture[1]=180;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue