mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
fix manabatery, fix timer clock skew, check queue when mouse move, wasd control
This commit is contained in:
parent
05a2803b2b
commit
56cac26206
17 changed files with 102 additions and 60 deletions
|
@ -5,7 +5,7 @@ project(skeldal)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
add_compile_options(/W4 /EHsc /DNOMINMAX /J)
|
add_compile_options(/W4 /EHsc /DNOMINMAX /J /DLOGFILE)
|
||||||
set(STANDARD_LIBRARIES "")
|
set(STANDARD_LIBRARIES "")
|
||||||
else()
|
else()
|
||||||
add_compile_options(-Wall -Wextra -Werror -Wno-unused-result -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat -funsigned-char)
|
add_compile_options(-Wall -Wextra -Werror -Wno-unused-result -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat -funsigned-char)
|
||||||
|
|
|
@ -653,12 +653,18 @@ void map_keyboard(EVENT_MSG *msg,void **usr)
|
||||||
c=d>>8;
|
c=d>>8;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'H':yr++;break;
|
case 17:
|
||||||
case 'P':yr--;break;
|
case 'H':yr--;break;
|
||||||
case 'M':xr--;break;
|
case 31:
|
||||||
case 'K':xr++;break;
|
case 'P':yr++;break;
|
||||||
|
case 32:
|
||||||
|
case 'M':xr++;break;
|
||||||
|
case 30:
|
||||||
|
case 'K':xr--;break;
|
||||||
|
case 16:
|
||||||
case 'Q':
|
case 'Q':
|
||||||
case 's':if (check_for_layer(cur_depth-1)) cur_depth--;break;
|
case 's':if (check_for_layer(cur_depth-1)) cur_depth--;break;
|
||||||
|
case 18:
|
||||||
case 'I':
|
case 'I':
|
||||||
case 't':if (check_for_layer(cur_depth+1)) cur_depth++;break;
|
case 't':if (check_for_layer(cur_depth+1)) cur_depth++;break;
|
||||||
case 15:
|
case 15:
|
||||||
|
|
|
@ -1261,8 +1261,6 @@ void render_scene(int sector, int smer)
|
||||||
draw_spectxtrs(s,-j,i);
|
draw_spectxtrs(s,-j,i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
do_events();
|
|
||||||
if (cancel_render) return;
|
|
||||||
}
|
}
|
||||||
calc_spectxtrs();
|
calc_spectxtrs();
|
||||||
if (lodka) {
|
if (lodka) {
|
||||||
|
|
|
@ -2185,7 +2185,7 @@ static void knock_mob_back(TMOB *mm,int dir)
|
||||||
if (itnum == 0) return;
|
if (itnum == 0) return;
|
||||||
const TITEM *it = glob_items + itnum-1;
|
const TITEM *it = glob_items + itnum-1;
|
||||||
if (it->druh != TYP_UTOC) return;
|
if (it->druh != TYP_UTOC) return;
|
||||||
int vls[] = {VLS_MGSIL_H,VLS_MGSIL_L,VLS_UTOK_H,VLS_UTOK_L,VLS_DAMAGE};
|
int vls[] = {VLS_UTOK_H,VLS_UTOK_L,VLS_DAMAGE};
|
||||||
for (size_t i = 0; i < countof(vls); ++i) {
|
for (size_t i = 0; i < countof(vls); ++i) {
|
||||||
vlastnosti[vls[i]] -= it->zmeny[vls[i]];
|
vlastnosti[vls[i]] -= it->zmeny[vls[i]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,7 +473,6 @@ static void zooming_forward_backward(const word *background,char back)
|
||||||
//phase=(float)sin(3.14159265*0.5f*phase);
|
//phase=(float)sin(3.14159265*0.5f*phase);
|
||||||
if (back) phase=-phase;
|
if (back) phase=-phase;
|
||||||
DxZoomWalk(buffer, SCREEN_OFFLINE, tpoints,phase, NULL);
|
DxZoomWalk(buffer, SCREEN_OFFLINE, tpoints,phase, NULL);
|
||||||
do_events();
|
|
||||||
}
|
}
|
||||||
while (curtime<maxtime);
|
while (curtime<maxtime);
|
||||||
DxDoneWalk(buffer);
|
DxDoneWalk(buffer);
|
||||||
|
@ -537,7 +536,6 @@ static void turn_left_right(char right)
|
||||||
phase=(curtime)*(1.0f/(float)maxtime);
|
phase=(curtime)*(1.0f/(float)maxtime);
|
||||||
//phase=(float)sin(3.14159265*0.5f*phase);
|
//phase=(float)sin(3.14159265*0.5f*phase);
|
||||||
DxTurn(buffer,SCREEN_OFFLINE,90,right?-phase:phase,NULL);
|
DxTurn(buffer,SCREEN_OFFLINE,90,right?-phase:phase,NULL);
|
||||||
do_events();
|
|
||||||
}
|
}
|
||||||
while (curtime<maxtime);
|
while (curtime<maxtime);
|
||||||
DxDoneTurn(buffer);
|
DxDoneTurn(buffer);
|
||||||
|
|
|
@ -207,14 +207,28 @@ void restore_items(TMPFILE_RD *f)
|
||||||
{
|
{
|
||||||
int32_t i,j;
|
int32_t i,j;
|
||||||
|
|
||||||
|
short **new_item_map = getmem(mapsize*4*sizeof(*map_items));
|
||||||
|
memset(new_item_map,0,mapsize*4*sizeof(*map_items));
|
||||||
|
while(temp_storage_read(&i,sizeof(i),f) && i!=-1) {
|
||||||
|
temp_storage_read(&j,sizeof(j),f);
|
||||||
|
new_item_map[i]=(short *)getmem(j*2);
|
||||||
|
temp_storage_read(new_item_map[i],2*j,f);
|
||||||
|
short *v = new_item_map[i];
|
||||||
|
while (*v) { //sanitize map items
|
||||||
|
if (*v < 1 || *v >= item_count) {
|
||||||
|
free(new_item_map[i]);
|
||||||
|
new_item_map[i] = map_items[i];
|
||||||
|
map_items[i] = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(i=0;i<mapsize*4;i++) if (map_items[i]!=NULL) free(map_items[i]);
|
for(i=0;i<mapsize*4;i++) if (map_items[i]!=NULL) free(map_items[i]);
|
||||||
memset(map_items,0,mapsize*4*sizeof(*map_items));
|
memset(map_items,0,mapsize*4*sizeof(*map_items));
|
||||||
while(temp_storage_read(&i,sizeof(i),f) && i!=-1)
|
map_items = new_item_map;
|
||||||
{
|
|
||||||
temp_storage_read(&j,sizeof(j),f);
|
|
||||||
map_items[i]=(short *)getmem(j*2);
|
|
||||||
temp_storage_read(map_items[i],2*j,f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern TSTR_LIST texty_v_mape;
|
extern TSTR_LIST texty_v_mape;
|
||||||
|
|
|
@ -1911,12 +1911,10 @@ void cast(int num,THUMAN *p,int owner, char backfire)
|
||||||
if (!backfire) p->mana-=k->mge;
|
if (!backfire) p->mana-=k->mge;
|
||||||
p->exp+=k->mge;
|
p->exp+=k->mge;
|
||||||
check_player_new_level(p);
|
check_player_new_level(p);
|
||||||
if (p->mana>p->mana_battery)
|
if (p->mana>p->mana_battery) {
|
||||||
{
|
p->mana=p->mana_battery;
|
||||||
if (p->mana_battery>=0)p->mana=p->mana_battery;
|
|
||||||
else
|
|
||||||
p->mana_battery=32767;
|
|
||||||
}
|
}
|
||||||
|
p->mana_battery=32767;
|
||||||
end:
|
end:
|
||||||
GlobEvent(MAGLOB_AFTERMAGIC,p->sektor,p->direction);
|
GlobEvent(MAGLOB_AFTERMAGIC,p->sektor,p->direction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1920,8 +1920,14 @@ void game_keyboard(EVENT_MSG *msg,void **usr)
|
||||||
while (_bios_keybrd(_KEYBRD_READY) ) _bios_keybrd(_KEYBRD_READ);
|
while (_bios_keybrd(_KEYBRD_READY) ) _bios_keybrd(_KEYBRD_READ);
|
||||||
switch (c >> 8)
|
switch (c >> 8)
|
||||||
{
|
{
|
||||||
|
case 17:
|
||||||
case 'H':step_zoom(0);break;
|
case 'H':step_zoom(0);break;
|
||||||
|
case 31:
|
||||||
case 'P':step_zoom(2);break;
|
case 'P':step_zoom(2);break;
|
||||||
|
case 30: step_zoom(3);break;
|
||||||
|
case 32: step_zoom(1);break;
|
||||||
|
case 16: turn_zoom(-1);break;
|
||||||
|
case 18: turn_zoom(1);break;
|
||||||
case 'M':if (get_control_key_state() & 0x80)
|
case 'M':if (get_control_key_state() & 0x80)
|
||||||
step_zoom(1);
|
step_zoom(1);
|
||||||
else
|
else
|
||||||
|
@ -1950,6 +1956,7 @@ void game_keyboard(EVENT_MSG *msg,void **usr)
|
||||||
case 1:konec(0,0,0,0,0);break;
|
case 1:konec(0,0,0,0,0);break;
|
||||||
// case 25:GamePause();break;
|
// case 25:GamePause();break;
|
||||||
case 28:enforce_start_battle();break;
|
case 28:enforce_start_battle();break;
|
||||||
|
case 45:
|
||||||
case 82:group_all();break;
|
case 82:group_all();break;
|
||||||
case '<':if (!battle && GlobEvent(MAGLOB_CLICKSAVE,viewsector,viewdir))
|
case '<':if (!battle && GlobEvent(MAGLOB_CLICKSAVE,viewsector,viewdir))
|
||||||
{unwire_proc();cancel_render=1;do_save_dialog();wire_proc();}break;
|
{unwire_proc();cancel_render=1;do_save_dialog();wire_proc();}break;
|
||||||
|
|
|
@ -440,9 +440,8 @@ void mouse_set_cursor(int cursor)
|
||||||
{
|
{
|
||||||
alock(cursor);
|
alock(cursor);
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
register_ms_cursor(ablock(cursor));
|
nastav_mysku_kurzor(ablock(cursor),0,0);
|
||||||
last_ms_cursor=cursor;
|
last_ms_cursor=cursor;
|
||||||
set_ms_finger(0,0);
|
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -454,8 +453,8 @@ void mouse_set_cursor(int cursor)
|
||||||
p=(char *)ablock(cursor/18+ikon_libs);
|
p=(char *)ablock(cursor/18+ikon_libs);
|
||||||
memcpy(ms_item,&p[(cursor%18)*IT_ICONE_SIZE],IT_ICONE_SIZE);
|
memcpy(ms_item,&p[(cursor%18)*IT_ICONE_SIZE],IT_ICONE_SIZE);
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
register_ms_cursor(ms_item);
|
nastav_mysku_kurzor(ms_item,45/2,55/2);
|
||||||
set_ms_finger(45/2,55/2);
|
|
||||||
last_ms_cursor=-cursor;
|
last_ms_cursor=-cursor;
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
}
|
}
|
||||||
|
@ -692,6 +691,7 @@ void user_timer(EVENT_MSG *msg,void **usr)
|
||||||
x=get_timer_value();
|
x=get_timer_value();
|
||||||
x-=lastvalue;
|
x-=lastvalue;
|
||||||
lastvalue+=x;
|
lastvalue+=x;
|
||||||
|
x = MIN(TIMERSPEED, x); //prevent clock skew
|
||||||
if (x) send_message(E_TIMER,x);
|
if (x) send_message(E_TIMER,x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1183,10 +1183,11 @@ void pouzij_zbran(THUMAN *p,int ruka)
|
||||||
}
|
}
|
||||||
vybrana_zbran=itm;
|
vybrana_zbran=itm;
|
||||||
bonus=vypocti_bonus(p,itm);
|
bonus=vypocti_bonus(p,itm);
|
||||||
if (itm>0)
|
if (itm>0) {
|
||||||
memcpy(&p->vlastnosti[VLS_MGSIL_L],&glob_items[itm-1].zmeny[VLS_MGSIL_L],3*sizeof(short));
|
memcpy(&p->vlastnosti[VLS_MGSIL_L],&glob_items[itm-1].zmeny[VLS_MGSIL_L],3*sizeof(short));
|
||||||
else
|
} else {
|
||||||
memset(&p->vlastnosti[VLS_MGSIL_L],0,3*sizeof(short));
|
memset(&p->vlastnosti[VLS_MGSIL_L],0,3*sizeof(short));
|
||||||
|
}
|
||||||
if (!itm || (it=&glob_items[itm-1])->druh==TYP_UTOC)
|
if (!itm || (it=&glob_items[itm-1])->druh==TYP_UTOC)
|
||||||
{
|
{
|
||||||
TMOB *m;int mm,chaos;
|
TMOB *m;int mm,chaos;
|
||||||
|
@ -1304,7 +1305,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje
|
||||||
if(nxt==-255)
|
if(nxt==-255)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SEND_LOG("(BATTLE) Ending round...(nxt=%d,mob=%s)",nxt,mobs[nxt].name);
|
// SEND_LOG("(BATTLE) Ending round...(nxt=%d,mob=%s)",nxt,mobs[nxt].name);
|
||||||
delete_from_timer(TM_SCENE);
|
delete_from_timer(TM_SCENE);
|
||||||
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
||||||
for(i=0;i<MAX_MOBS;i++)
|
for(i=0;i<MAX_MOBS;i++)
|
||||||
|
@ -2133,12 +2134,17 @@ void programming_keyboard(EVENT_MSG *msg,void **unused)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 1:konec(0,0,0,0,0);break;
|
case 1:konec(0,0,0,0,0);break;
|
||||||
|
case 18:
|
||||||
case 'M':souboje_turn(1);break;
|
case 'M':souboje_turn(1);break;
|
||||||
|
case 16:
|
||||||
case 'K':souboje_turn(-1);break;
|
case 'K':souboje_turn(-1);break;
|
||||||
case '=':unwire_proc();cancel_render=1;wire_save_load(0);break;
|
case '=':unwire_proc();cancel_render=1;wire_save_load(0);break;
|
||||||
case '>':game_setup(0,0,0,0,0);break;
|
case '>':game_setup(0,0,0,0,0);break;
|
||||||
case 57:souboje_dalsi();bott_draw(1);break;
|
case 57:souboje_dalsi();bott_draw(1);break;
|
||||||
case 15:
|
case 15:
|
||||||
|
case 28:zahajit_kolo(0);
|
||||||
|
souboje_stisknout(AC_START);
|
||||||
|
break;
|
||||||
case 50:
|
case 50:
|
||||||
if (GlobEvent(MAGLOB_BEFOREMAPOPEN,viewsector,viewdir))
|
if (GlobEvent(MAGLOB_BEFOREMAPOPEN,viewsector,viewdir))
|
||||||
show_automap(1);
|
show_automap(1);
|
||||||
|
|
|
@ -33,6 +33,17 @@ void ukaz_mysku()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nastav_mysku_kurzor(const void *mscursor, int finger_x, int finger_y) {
|
||||||
|
register_ms_cursor(mscursor);
|
||||||
|
h_x = finger_x;
|
||||||
|
h_y = finger_y;
|
||||||
|
#ifndef FORCE_SOFTWARE_CURSOR
|
||||||
|
cur_hw_mouse = mscursor;
|
||||||
|
game_display_show_mouse(mscursor,h_x, h_y);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void schovej_mysku()
|
void schovej_mysku()
|
||||||
{
|
{
|
||||||
#ifdef FORCE_SOFTWARE_CURSOR
|
#ifdef FORCE_SOFTWARE_CURSOR
|
||||||
|
@ -107,6 +118,9 @@ void set_ms_finger(int x,int y)
|
||||||
{
|
{
|
||||||
h_x=x;
|
h_x=x;
|
||||||
h_y=y;
|
h_y=y;
|
||||||
|
#ifndef FORCE_SOFTWARE_CURSOR
|
||||||
|
game_display_show_mouse(cur_hw_mouse,h_x, h_y);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ extern MS_EVENT ms_last_event;
|
||||||
short init_mysky(void);
|
short init_mysky(void);
|
||||||
short done_mysky(void);
|
short done_mysky(void);
|
||||||
void ukaz_mysku(void);
|
void ukaz_mysku(void);
|
||||||
|
void nastav_mysku_kurzor(const void *mscursor, int finger_x, int finger_y);
|
||||||
void schovej_mysku(void);
|
void schovej_mysku(void);
|
||||||
void zobraz_mysku(void);
|
void zobraz_mysku(void);
|
||||||
void set_ms_finger(int x,int y);
|
void set_ms_finger(int x,int y);
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define __attribute__(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
void send_log_impl(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
void send_log_impl(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||||
#define SEND_LOG(...) send_log_impl( __VA_ARGS__)
|
#define SEND_LOG(...) send_log_impl( __VA_ARGS__)
|
||||||
|
|
|
@ -705,7 +705,7 @@ void *grealloc(void *p,int32_t size)
|
||||||
q=realloc(p,size);
|
q=realloc(p,size);
|
||||||
if (q!=NULL)
|
if (q!=NULL)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ALLOC) **** Realloc: New %p size %d\n",q,*((int32_t *)q-1));
|
// SEND_LOG("(ALLOC) **** Realloc: New %p size %d\n",q,*((int32_t *)q-1));
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
q=getmem(size);
|
q=getmem(size);
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static std::uint32_t gtick = get_game_tick_count();
|
static std::uint32_t gtick = get_game_tick_count();
|
||||||
|
@ -15,13 +18,19 @@ void send_log_impl(const char *format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
int task = q_current_task();
|
int task = q_current_task();
|
||||||
char buff2[1000];
|
char buff2[1000];
|
||||||
|
char buff[1000];
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
auto reltik = get_game_tick_count() - gtick;
|
auto reltik = get_game_tick_count() - gtick;
|
||||||
double sec = reltik * 0.001;
|
double sec = reltik * 0.001;
|
||||||
std::cerr << sec << "[" << task << "]";
|
|
||||||
vsnprintf(buff2,1000,format, args);
|
vsnprintf(buff2,1000,format, args);
|
||||||
std::cerr << buff2 << std::endl;
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
snprintf(buff, sizeof(buff), "%f [%d] %s\r\n", sec, task, buff2);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
OutputDebugStringA(buff);
|
||||||
|
#else
|
||||||
|
std::cerr << buff;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,14 +298,8 @@ void SDLContext::event_loop(std::stop_token stp) {
|
||||||
if (_mouse) {
|
if (_mouse) {
|
||||||
_mouse_rect.x = e.motion.x;
|
_mouse_rect.x = e.motion.x;
|
||||||
_mouse_rect.y = e.motion.y;
|
_mouse_rect.y = e.motion.y;
|
||||||
bool do_update = false;
|
update_screen(true);
|
||||||
{
|
|
||||||
std::lock_guard _(_mx);
|
|
||||||
do_update = _display_update_queue.empty();
|
|
||||||
}
|
|
||||||
if (do_update) {
|
|
||||||
refresh_screen();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
||||||
int button = e.button.button;
|
int button = e.button.button;
|
||||||
|
@ -357,7 +351,6 @@ void SDLContext::show_slide_transition(const SDL_Rect &visible_from,
|
||||||
const SDL_Rect &visible_where, const SDL_Rect &hidden_from,
|
const SDL_Rect &visible_where, const SDL_Rect &hidden_from,
|
||||||
const SDL_Rect &hidden_where) {
|
const SDL_Rect &hidden_where) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::slide_transition);
|
push_item(DisplayRequest::slide_transition);
|
||||||
push_item(SlideTransitionReq{visible_from, visible_where,hidden_from, hidden_where});
|
push_item(SlideTransitionReq{visible_from, visible_where,hidden_from, hidden_where});
|
||||||
}
|
}
|
||||||
|
@ -435,10 +428,13 @@ void SDLContext::refresh_screen() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::update_screen() {
|
void SDLContext::update_screen(bool force_refresh) {
|
||||||
{
|
{
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
if (_display_update_queue.empty()) return;
|
if (_display_update_queue.empty()) {
|
||||||
|
if (force_refresh) refresh_screen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
QueueIter iter = _display_update_queue.data();
|
QueueIter iter = _display_update_queue.data();
|
||||||
QueueIter end = iter + _display_update_queue.size();
|
QueueIter end = iter + _display_update_queue.size();
|
||||||
while (iter != end) {
|
while (iter != end) {
|
||||||
|
@ -581,12 +577,14 @@ void SDLContext::push_item(const T &item) {
|
||||||
auto b = reinterpret_cast<const char *>(&item);
|
auto b = reinterpret_cast<const char *>(&item);
|
||||||
auto e = b + sizeof(T);
|
auto e = b + sizeof(T);
|
||||||
auto sz = _display_update_queue.size();
|
auto sz = _display_update_queue.size();
|
||||||
|
if (sz == 0) signal_push();
|
||||||
_display_update_queue.resize(sz + sizeof(T));
|
_display_update_queue.resize(sz + sizeof(T));
|
||||||
std::copy(b, e, _display_update_queue.begin()+sz);
|
std::copy(b, e, _display_update_queue.begin()+sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::push_item(const std::string_view &item) {
|
void SDLContext::push_item(const std::string_view &item) {
|
||||||
auto sz = _display_update_queue.size();
|
auto sz = _display_update_queue.size();
|
||||||
|
if (sz == 0) signal_push();
|
||||||
_display_update_queue.resize(sz + item.size());
|
_display_update_queue.resize(sz + item.size());
|
||||||
std::copy(item.begin(), item.end(), _display_update_queue.begin()+sz);
|
std::copy(item.begin(), item.end(), _display_update_queue.begin()+sz);
|
||||||
}
|
}
|
||||||
|
@ -620,20 +618,17 @@ std::string_view SDLContext::pop_data(QueueIter &iter, std::size_t size) {
|
||||||
|
|
||||||
void SDLContext::swap_render_buffers() {
|
void SDLContext::swap_render_buffers() {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::swap_render_buffers);
|
push_item(DisplayRequest::swap_render_buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::swap_display_buffers() {
|
void SDLContext::swap_display_buffers() {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::swap_visible_buffers);
|
push_item(DisplayRequest::swap_visible_buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::show_blend_transition(const SDL_Rect &wrkarea, const SDL_Rect &prev,
|
void SDLContext::show_blend_transition(const SDL_Rect &wrkarea, const SDL_Rect &prev,
|
||||||
const SDL_Rect &next, float phase) {
|
const SDL_Rect &next, float phase) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::blend_transition);
|
push_item(DisplayRequest::blend_transition);
|
||||||
push_item(BlendTransitionReq{wrkarea, prev, next, phase});
|
push_item(BlendTransitionReq{wrkarea, prev, next, phase});
|
||||||
}
|
}
|
||||||
|
@ -780,7 +775,6 @@ void SDLContext::push_hi_image(const unsigned short *image) {
|
||||||
|
|
||||||
void SDLContext::show_mouse_cursor(const unsigned short *ms_hi_format, SDL_Point finger) {
|
void SDLContext::show_mouse_cursor(const unsigned short *ms_hi_format, SDL_Point finger) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::show_mouse_cursor);
|
push_item(DisplayRequest::show_mouse_cursor);
|
||||||
push_hi_image(ms_hi_format);
|
push_hi_image(ms_hi_format);
|
||||||
_mouse_finger = finger;
|
_mouse_finger = finger;
|
||||||
|
@ -788,14 +782,12 @@ void SDLContext::show_mouse_cursor(const unsigned short *ms_hi_format, SDL_Point
|
||||||
|
|
||||||
void SDLContext::hide_mouse_cursor() {
|
void SDLContext::hide_mouse_cursor() {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::hide_mouse_cursor);
|
push_item(DisplayRequest::hide_mouse_cursor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::load_sprite(int sprite_id, const unsigned short *hi_image) {
|
void SDLContext::load_sprite(int sprite_id, const unsigned short *hi_image) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_load);
|
push_item(DisplayRequest::sprite_load);
|
||||||
push_item(sprite_id);
|
push_item(sprite_id);
|
||||||
push_hi_image(hi_image);
|
push_hi_image(hi_image);
|
||||||
|
@ -804,7 +796,6 @@ void SDLContext::load_sprite(int sprite_id, const unsigned short *hi_image) {
|
||||||
|
|
||||||
void SDLContext::place_sprite(int sprite_id, int x, int y) {
|
void SDLContext::place_sprite(int sprite_id, int x, int y) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_place);
|
push_item(DisplayRequest::sprite_place);
|
||||||
push_item(sprite_id);
|
push_item(sprite_id);
|
||||||
SDL_Point pt{x,y};
|
SDL_Point pt{x,y};
|
||||||
|
@ -814,7 +805,6 @@ void SDLContext::place_sprite(int sprite_id, int x, int y) {
|
||||||
|
|
||||||
void SDLContext::scale_sprite(int sprite_id, int x, int y, int w, int h) {
|
void SDLContext::scale_sprite(int sprite_id, int x, int y, int w, int h) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_scale);
|
push_item(DisplayRequest::sprite_scale);
|
||||||
push_item(sprite_id);
|
push_item(sprite_id);
|
||||||
SDL_Rect pt{x,y,w,h};
|
SDL_Rect pt{x,y,w,h};
|
||||||
|
@ -823,14 +813,12 @@ void SDLContext::scale_sprite(int sprite_id, int x, int y, int w, int h) {
|
||||||
|
|
||||||
void SDLContext::hide_sprite(int sprite_id) {
|
void SDLContext::hide_sprite(int sprite_id) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_hide);
|
push_item(DisplayRequest::sprite_hide);
|
||||||
push_item(sprite_id);
|
push_item(sprite_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::sprite_set_zindex(int sprite_id, int zindex) {
|
void SDLContext::sprite_set_zindex(int sprite_id, int zindex) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_hide);
|
push_item(DisplayRequest::sprite_hide);
|
||||||
push_item(sprite_id);
|
push_item(sprite_id);
|
||||||
push_item(zindex);
|
push_item(zindex);
|
||||||
|
@ -838,7 +826,6 @@ void SDLContext::sprite_set_zindex(int sprite_id, int zindex) {
|
||||||
|
|
||||||
void SDLContext::unload_sprite(int sprite) {
|
void SDLContext::unload_sprite(int sprite) {
|
||||||
std::lock_guard _(_mx);
|
std::lock_guard _(_mx);
|
||||||
signal_push();
|
|
||||||
push_item(DisplayRequest::sprite_unload);
|
push_item(DisplayRequest::sprite_unload);
|
||||||
push_item(sprite);
|
push_item(sprite);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
void event_loop(std::stop_token stp);
|
void event_loop(std::stop_token stp);
|
||||||
void update_screen();
|
void update_screen(bool force_refresh = false);
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue