Skip to content

Commit

Permalink
Fix nothing tile display in editor #475
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Feb 26, 2020
1 parent 84ce382 commit fc94520
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 38 deletions.
5 changes: 5 additions & 0 deletions src/cdogsed/nk_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ void DrawPic(
bounds.w = pic->size.x * scale;
bounds.h = pic->size.y * scale;
}
else
{
bounds.w = 0;
bounds.h = 0;
}
nk_draw_image(&ctx->current->buffer, bounds, &tex, nk_white);
}

Expand Down
79 changes: 41 additions & 38 deletions src/cdogsed/tile_brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,45 +246,48 @@ static void DrawTilePropsRow(
TileClassInitDefault(selectedTC, tbData->pm, base, NULL, &selectedTC->Mask);
}

nk_label(ctx, "Style:", NK_TEXT_LEFT);
const GLuint *styleTexIds = NULL;
const char *styles = "";
int styleSelected = -1;
int styleCount = 0;
switch (selectedTC->Type)
if (selectedTC->Type != TILE_CLASS_NOTHING)
{
case TILE_CLASS_FLOOR:
styles = tbData->floorStyles;
styleSelected = FloorStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsFloorStyles.data;
styleCount = tbData->texIdsFloorStyles.size;
break;
case TILE_CLASS_WALL:
styles = tbData->wallStyles;
styleSelected = WallStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsWallStyles.data;
styleCount = tbData->texIdsWallStyles.size;
break;
case TILE_CLASS_DOOR:
styles = tbData->doorStyles;
styleSelected = DoorStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsDoorStyles.data;
styleCount = tbData->texIdsDoorStyles.size;
break;
default:
break;
}
const int newStyle = nk_combo_separator_image(
ctx, styleTexIds, styles, '\0', styleSelected,
styleCount, ROW_HEIGHT,
nk_vec2(nk_widget_width(ctx), 8 * ROW_HEIGHT)
);
if (newStyle != styleSelected)
{
CFREE(selectedTC->Style);
CSTRDUP(
selectedTC->Style, IndexTileStyleName(selectedTC->Type, newStyle));
TileClassReloadPic(selectedTC, tbData->pm);
nk_label(ctx, "Style:", NK_TEXT_LEFT);
const GLuint* styleTexIds = NULL;
const char* styles = "";
int styleSelected = -1;
int styleCount = 0;
switch (selectedTC->Type)
{
case TILE_CLASS_FLOOR:
styles = tbData->floorStyles;
styleSelected = FloorStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsFloorStyles.data;
styleCount = tbData->texIdsFloorStyles.size;
break;
case TILE_CLASS_WALL:
styles = tbData->wallStyles;
styleSelected = WallStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsWallStyles.data;
styleCount = tbData->texIdsWallStyles.size;
break;
case TILE_CLASS_DOOR:
styles = tbData->doorStyles;
styleSelected = DoorStyleIndex(selectedTC->Style);
styleTexIds = tbData->texIdsDoorStyles.data;
styleCount = tbData->texIdsDoorStyles.size;
break;
default:
break;
}
const int newStyle = nk_combo_separator_image(
ctx, styleTexIds, styles, '\0', styleSelected,
styleCount, ROW_HEIGHT,
nk_vec2(nk_widget_width(ctx), 8 * ROW_HEIGHT)
);
if (newStyle != styleSelected)
{
CFREE(selectedTC->Style);
CSTRDUP(
selectedTC->Style, IndexTileStyleName(selectedTC->Type, newStyle));
TileClassReloadPic(selectedTC, tbData->pm);
}
}
}
static void DrawTileClass(
Expand Down

0 comments on commit fc94520

Please sign in to comment.