Add charviewer utility for viewing character / sprite files
This commit is contained in:
@@ -51,6 +51,7 @@ ErrorContext *character_sprite_add(character *basechar, sprite *ref, int state)
|
||||
|
||||
ErrorContext *character_sprite_get(character *basechar, int state, sprite **dest)
|
||||
{
|
||||
sprite *target = NULL;
|
||||
PREPARE_ERROR(errctx);
|
||||
char stateval[32];
|
||||
FAIL_ZERO_RETURN(errctx, dest, ERR_NULLPOINTER, "NULL pointer to sprite pointer (**dest)");
|
||||
@@ -59,6 +60,8 @@ ErrorContext *character_sprite_get(character *basechar, int state, sprite **dest
|
||||
SDL_itoa(state, (char *)&stateval, 10);
|
||||
*dest = (sprite *)SDL_GetPointerProperty(basechar->state_sprites, (char *)&stateval, NULL);
|
||||
FAIL_ZERO_RETURN(errctx, *dest, ERR_KEY, "Sprite for state %d (%s) not found in the character's registry", state, (char *)&stateval);
|
||||
target = *dest;
|
||||
SDL_Log("Sprite state %d (%s) has character %s", state, (char *)&stateval, target->name);
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ ErrorContext *controller_handle_event(void *appstate, SDL_Event *event)
|
||||
if ( curmap->target == NULL ) {
|
||||
continue;
|
||||
}
|
||||
SDL_Log("Control map %d maps to actor %s", i, curmap->target->name);
|
||||
SDL_Log("event from keyboard %d", event->key.which);
|
||||
//SDL_Log("Control map %d maps to actor %s", i, curmap->target->name);
|
||||
//SDL_Log("event from keyboard %d", event->key.which);
|
||||
for ( j = 0; j < MAX_CONTROLS; j++ ) {
|
||||
curcontrol = &curmap->controls[j];
|
||||
//SDL_Log("button/key is processed by controlmap %d control %d", i, j);
|
||||
@@ -32,20 +32,24 @@ ErrorContext *controller_handle_event(void *appstate, SDL_Event *event)
|
||||
eventButtonComboMatch = (
|
||||
((event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN ||
|
||||
event->type == SDL_EVENT_GAMEPAD_BUTTON_UP) &&
|
||||
event->gbutton.which == curmap->jsid &&
|
||||
event->gbutton.button == curcontrol->button) ||
|
||||
((event->type == SDL_EVENT_KEY_DOWN ||
|
||||
event->type == SDL_EVENT_KEY_UP) &&
|
||||
event->key.which == curmap->kbid &&
|
||||
event->key.key == curcontrol->key)
|
||||
);
|
||||
if ( event->type == curcontrol->event_on && eventButtonComboMatch) {
|
||||
SDL_Log("event %d (button %d / key %d) ACTIVATES controlmap %d control %d", event->type, event->gbutton.which, event->key.which, i, j);
|
||||
SDL_Log("event %d (button %d / key %d) ACTIVATES controlmap %d control %d", event->type, event->gbutton.which, event->key.key, i, j);
|
||||
BITMASK_DEL(curmap->target->state, curcontrol->target_del_state_on);
|
||||
BITMASK_ADD(curmap->target->state, curcontrol->target_add_state_on);
|
||||
SDL_Log("new target actor state: %d", curmap->target->state);
|
||||
goto _controller_handle_event_success;
|
||||
} else if ( event->type == curcontrol->event_off && eventButtonComboMatch ) {
|
||||
SDL_Log("event %d (button %d / key %d) DE-ACTIVATES controlmap %d control %d", event->type, event->gbutton.which, event->key.which, i, j);
|
||||
SDL_Log("event %d (button %d / key %d) DE-ACTIVATES controlmap %d control %d", event->type, event->gbutton.which, event->key.key, i, j);
|
||||
BITMASK_DEL(curmap->target->state, curcontrol->target_del_state_off);
|
||||
BITMASK_ADD(curmap->target->state, curcontrol->target_add_state_off);
|
||||
SDL_Log("new target actor state: %d", curmap->target->state);
|
||||
goto _controller_handle_event_success;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user