mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-08-15 10:48:22 -04:00
prepare launcher for UGC
This commit is contained in:
parent
86d0919905
commit
4ed39ec344
11 changed files with 342 additions and 121 deletions
152
game/interfac.c
152
game/interfac.c
|
@ -18,10 +18,11 @@
|
|||
#include <ctype.h>
|
||||
#include <libs/gui.h>
|
||||
#include <libs/basicobj.h>
|
||||
#include <libs/strlists.h>
|
||||
#include <time.h>
|
||||
#include <libs/mgfplay.h>
|
||||
#include <libs/wav.h>
|
||||
#include <fcntl.h>
|
||||
#include <platform/ugc.h>
|
||||
#include "globals.h"
|
||||
#include "engine1.h"
|
||||
#include <stdarg.h>
|
||||
|
@ -1627,81 +1628,90 @@ char ask_save_dialog(char *name_buffer, size_t name_size, char allow_remove) {
|
|||
|
||||
}
|
||||
|
||||
#if 0
|
||||
//----------------- JRC LOGO ----------------------------------
|
||||
static char *launcher_ddl_file = NULL;
|
||||
static void free_ddl_file_name(void) {
|
||||
free(launcher_ddl_file);
|
||||
}
|
||||
|
||||
#define SHOWDELAY 125
|
||||
#define SHOWDEND (SHOWDELAY-32)
|
||||
const char *run_launcher() {
|
||||
const char *str_label = texty[198];
|
||||
TSTR_LIST lst = create_list(100);
|
||||
TSTR_LIST ddl_lst = create_list(100);
|
||||
CTL3D ctl = {0,0,4,0};
|
||||
int selected = 0;
|
||||
size_t item_count = 1;
|
||||
|
||||
typedef struct _hicolpal
|
||||
{
|
||||
unsigned blue:5;
|
||||
unsigned green:5;
|
||||
unsigned red:5;
|
||||
}HICOLPAL;
|
||||
|
||||
void show_jrc_logo(char *filename)
|
||||
{
|
||||
char *pcx;word *pcxw;
|
||||
char bnk=1;
|
||||
int xp,yp,i;
|
||||
word palette[256],*palw;
|
||||
int cntr,cdiff,cpalf,ccc;
|
||||
|
||||
change_music(NULL);
|
||||
curcolor=0;bar32(0,0,639,479);
|
||||
showview(0,0,0,0);sleep_ms(1000);
|
||||
const char *s = build_pathname(2, gpathtable[SR_VIDEO],filename);
|
||||
if (open_pcx(s,A_8BIT,&pcx)) return;
|
||||
pcxw=(word *)pcx;
|
||||
xp=pcxw[0];
|
||||
yp=pcxw[1];
|
||||
palw=pcxw+3;
|
||||
memcpy(palette,palw,256*sizeof(word));
|
||||
memset(palw,0,256*sizeof(word));
|
||||
xp/=2;yp/=2;xp=320-xp;yp=240-yp;
|
||||
cntr=get_timer_value();ccc=0;
|
||||
do
|
||||
{
|
||||
cdiff=(get_timer_value()-cntr)/2;
|
||||
if (cdiff<SHOWDEND && ccc!=cdiff)
|
||||
{
|
||||
cpalf=cdiff;
|
||||
if (cpalf<32)
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
int r=(cpalf<<11),g=(cpalf<<6),b=cpalf,k;
|
||||
k=palette[i] & 0xF800;if (k>r) palw[i]=r;else palw[i]=k;
|
||||
k=palette[i] & 0x7e0;if (k>g) palw[i]|=g;else palw[i]|=k;
|
||||
k=palette[i] & 0x1f;if (k>b) palw[i]|=b;else palw[i]|=k;
|
||||
UGCManager *ugc = UGC_create();
|
||||
size_t ugccount = UGC_Fetch(ugc);;
|
||||
for (size_t i = 0; i < ugccount; ++i) {
|
||||
UGCItem item = UGC_GetItem(ugc, i);
|
||||
char buff[60];
|
||||
const char *title = item.name;
|
||||
size_t tlen = strlen(title);
|
||||
const char *author = item.author;
|
||||
size_t alen = strlen(author);
|
||||
size_t reserve = sizeof(buff)-4;
|
||||
char d1 = 0;
|
||||
char d2 = 0;
|
||||
if (tlen + alen > reserve) {
|
||||
if (alen < reserve/2) {tlen = reserve - alen - 3;d1 = 1;}
|
||||
else if (tlen < reserve/2) {alen = reserve - tlen - 3;d2=1;}
|
||||
else {
|
||||
tlen = reserve/2-3; d1 = 1;
|
||||
alen = reserve/2-3; d2 = 1;
|
||||
}
|
||||
}
|
||||
char *iter = buff;
|
||||
for (size_t i = 0; i < tlen; ++i) *iter++ = title[i];
|
||||
if (d1) for (size_t i = 0; i < 3; ++i) *iter++='.';
|
||||
memcpy(iter, " - ",3); iter+=3;
|
||||
for (size_t i = 0; i < alen; ++i) *iter++ = author[i];
|
||||
if (d2) for (size_t i = 0; i < 3; ++i) *iter++='.';
|
||||
*iter = 0;
|
||||
str_add(&lst, buff);
|
||||
str_add(&ddl_lst, item.ddl_path);
|
||||
++item_count;
|
||||
}
|
||||
else if (ccc!=cdiff)
|
||||
{
|
||||
cpalf=SHOWDELAY-cdiff;
|
||||
if (cpalf<32)
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
int r,g,b,k=32-cpalf;
|
||||
|
||||
b=palette[i];g=b>>5;b&=0x1f;r=g>>6;g&=0x1f;
|
||||
b-=k;r-=k;g-=k;
|
||||
if (b<0) b=0;
|
||||
if (r<0) r=0;
|
||||
if (g<0) g=0;
|
||||
palw[i]=b | (r<<11) | (g<<6);
|
||||
}
|
||||
str_add(&lst, texty[199]);
|
||||
str_add(&ddl_lst, "");
|
||||
|
||||
|
||||
curcolor = RGB555(0,0,0);
|
||||
set_font(H_FBIG,RGB555_ALPHA(31,31,31));
|
||||
add_window(120,60,400,300,H_WINTXTR,3,20,20);
|
||||
define(-1,20,10,1,1,0,label,str_label);
|
||||
set_font(H_FKNIHA,RGB555_ALPHA(31,31,31));
|
||||
define(9,15,38,335,212,0,&listbox,lst,RGB555(16,16,16),0);
|
||||
property(&ctl,NULL,NULL,RGB555(0,0,0));c_default(0);
|
||||
if (item_count>19) {
|
||||
define(10,355,38,20,212,0,scroll_bar_v,0,item_count-19,19,RGB555(8,8,8));
|
||||
property(&ctl,NULL,NULL,RGB555(10,10,10));
|
||||
}
|
||||
put_picture(xp, yp, pcx);
|
||||
if (bnk) {
|
||||
showview(xp, yp, pcxw[0], pcxw[1]);
|
||||
}
|
||||
ccc=cdiff;
|
||||
mix_back_sound(0);
|
||||
}
|
||||
while (cdiff<SHOWDELAY && !_bios_keybrd(_KEYBRD_READY));
|
||||
curcolor=0;bar32(0,0,639,479);
|
||||
showview(0,0,0,0);
|
||||
free(pcx);
|
||||
}
|
||||
#endif
|
||||
define(20,20,20,60,20,2,button,texty[43]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
|
||||
define(30,90,20,60,20,2,button,texty[80]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
|
||||
redraw_window();
|
||||
send_message(E_ADD,E_KEYBOARD,save_dialog_keyboards);
|
||||
send_message(E_ADD,E_MOUSE,save_dialog_keyboards);
|
||||
escape();
|
||||
send_message(E_DONE,E_KEYBOARD,save_dialog_keyboards);
|
||||
send_message(E_DONE,E_MOUSE,save_dialog_keyboards);
|
||||
int butt = o_aktual->id;
|
||||
get_value(0,9,&selected);
|
||||
char *selddl = strdup(ddl_lst[selected]);
|
||||
release_list(lst);
|
||||
release_list(ddl_lst);
|
||||
close_current();
|
||||
if (butt != 30 || selddl == NULL || selddl[0] == 0) {
|
||||
free(selddl);
|
||||
UGC_Destroy(ugc);
|
||||
return butt != 30?NULL:"";
|
||||
}
|
||||
launcher_ddl_file = selddl;
|
||||
UGC_StartPlay(ugc, selected);
|
||||
UGC_Destroy(ugc);
|
||||
atexit(&free_ddl_file_name);
|
||||
return launcher_ddl_file;
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
#include <libs/mgfplay.h>
|
||||
#include <libs/inicfg.h>
|
||||
#include <platform/save_folder.h>
|
||||
#include <platform/ugc.h>
|
||||
#include "globals.h"
|
||||
#include "resources.h"
|
||||
//
|
||||
|
@ -825,6 +826,8 @@ void cti_texty(void)
|
|||
//patch stringtable
|
||||
if (!texty[98]) str_replace(&texty,98,"Ulo\x91it hru jako");
|
||||
if (!texty[99]) str_replace(&texty,99,"CRT Filter (>720p)");
|
||||
if (!texty[198]) str_replace(&texty,198,"Zvol dobrodru\x91stv\xA1");
|
||||
if (!texty[199]) str_replace(&texty,199,"Br\xA0ny Skeldalu (p\x96vodn\xA1 dobrodru\x91stv\xA1)");
|
||||
str_replace(&texty, 144, "Zrychlit souboje");
|
||||
str_replace(&texty, 51, "Celkov\x88 Hudba Efekty V\x98\xA8ky Basy Rychlost");
|
||||
str_replace(&texty,0,"Byl nalezen p\xA9ipojen\x98 ovlada\x87\nPro aktivaci ovlada\x87""e stiskn\x88te kter\x82koliv tla\x87\xA1tko na ovlada\x87i");
|
||||
|
@ -888,14 +891,17 @@ const void *boldcz;
|
|||
void init_DDL_manager() {
|
||||
|
||||
const char *ddlfile = build_pathname(2, gpathtable[SR_DATA],"SKELDAL.DDL");
|
||||
ddlfile = local_strdup(ddlfile);
|
||||
ddlfile = local_strdup(ddlfile);
|
||||
|
||||
init_manager();
|
||||
for (size_t sz = countof(patch_files); sz > 0;) {
|
||||
--sz;
|
||||
if (patch_files[sz]) {
|
||||
if (!add_patch_file(patch_files[sz])) {
|
||||
display_error("Can't open resource file (adv_patch): %s", patch_files[sz]);
|
||||
if (!add_patch_file(ddlfile)) {
|
||||
display_error("Can't open resource file (main): %s", ddlfile);
|
||||
abort();
|
||||
}
|
||||
for (size_t i = 0; i <= countof(patch_files); ++i) {
|
||||
if (patch_files[i]) {
|
||||
if (!add_patch_file(patch_files[i])) {
|
||||
display_error("Can't open resource file (adv_patch): %s", patch_files[i]);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -906,10 +912,6 @@ void init_DDL_manager() {
|
|||
gfx = local_strdup(gfx);
|
||||
add_patch_file(gfx);
|
||||
}
|
||||
if (!add_patch_file(ddlfile)) {
|
||||
display_error("Can't open resource file (main): %s", ddlfile);
|
||||
abort();
|
||||
}
|
||||
|
||||
SEND_LOG("(GAME) Memory manager initialized. Using DDL: '%s'",ddlfile);
|
||||
|
||||
|
@ -1196,22 +1198,8 @@ void enter_game(void)
|
|||
}
|
||||
|
||||
|
||||
static int update_config(void)
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void help(void)
|
||||
{
|
||||
printf("Pouziti:\n\n S <filename.MAP> <start_sector>\n\n"
|
||||
"<filename.MAP> jmeno mapy\n"
|
||||
"<start_sector> Cislo startovaciho sektoru\n"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
extern char nofloors;
|
||||
|
||||
/*
|
||||
|
@ -1496,11 +1484,6 @@ static void start_from_mapedit(va_list args)
|
|||
}
|
||||
#endif
|
||||
|
||||
void disable_intro(void)
|
||||
{
|
||||
add_field_num(&cur_config,sinit[12].heslo,1);
|
||||
update_config();
|
||||
}
|
||||
|
||||
/*
|
||||
* -char def_path[]="";
|
||||
|
@ -1560,6 +1543,8 @@ const char *configure_pathtable(const INI_CONFIG *cfg) {
|
|||
if (ini_get_boolean(paths, "patch_mode", 0)) {
|
||||
mman_patch = 1;
|
||||
}
|
||||
const char *ugc_path = ini_get_string(paths, "local_ugc", "adv");
|
||||
UGCSetLocalFoler(ugc_path);
|
||||
|
||||
return groot;
|
||||
}
|
||||
|
@ -1610,6 +1595,7 @@ int skeldal_gen_string_table_entry_point(const SKELDAL_CONFIG *start_cfg, const
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *run_launcher();
|
||||
int skeldal_entry_point(const SKELDAL_CONFIG *start_cfg)
|
||||
{
|
||||
def_mman_group_table(gpathtable);
|
||||
|
@ -1665,21 +1651,29 @@ int skeldal_entry_point(const SKELDAL_CONFIG *start_cfg)
|
|||
|
||||
init_skeldal(cfg);
|
||||
|
||||
if (start_cfg->launcher) {
|
||||
const char *ddl = run_launcher();
|
||||
if (ddl==NULL) goto cleanup;
|
||||
if (ddl[0]) {
|
||||
add_patch_file(ddl);
|
||||
reload_ddls();
|
||||
}
|
||||
}
|
||||
|
||||
int start_task = add_task(65536,start);
|
||||
|
||||
escape();
|
||||
|
||||
term_task_wait(start_task);
|
||||
|
||||
cleanup:;
|
||||
closemode();
|
||||
|
||||
|
||||
ini_close(cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue