// I have no index... static void create_tild_multi_layers(Entity *mod_description, int tild, Entity **map, Entity *desc, int pos, int width) { Entity *sp = yeGetByStrFast(desc, "start_pos"); int start_pos = yeGetInt(yeGetByIdx(sp, 0)) + yeGetInt(yeGetByIdx(sp, 0)) * (width ? width : 8000); if (start_pos == pos) { yePushBack(yeCreateArrayAt(map[1], NULL, pos), yeGetByStrFast(desc, "start_id"), NULL); } Y_BLOCK_ARRAY_FOREACH_PTR(YE_TO_ARRAY(mod_description)->values, tmp, it, ArrayEntry) { const char *char_str; if (!tmp) continue; char_str = yeGetString(yeGetByStr(tmp->entity, "map-char")); if (char_str[0] == tild) { if (yeStringIndexChar(yeGetByStrFast(desc, "ground_char"), char_str) >= 0) { yeCreateInt(it, yeCreateArrayAt(map[0], NULL, pos), NULL); } else { yeCreateInt(it, yeCreateArrayAt(map[2], NULL, pos), NULL); } return; } } yeCreateInt(tild, yeCreateArrayAt(map[0], NULL, pos), NULL); }
Entity *ywMapGetCase(YWidgetState *state, Entity *pos) { Entity *map = yeGet(state->entity, "map"); int w = yeGetInt(yeGet(state->entity, "width")); return yeGet(map, yeGetInt(yeGet(pos, "x")) + (w * yeGetInt(yeGet(pos, "y")))); }
int ywMapGetIdByElem(Entity *mapElem) { if (yeType(mapElem) == YINT) return yeGetInt(mapElem); if (yeType(mapElem) == YARRAY) return yeGetInt(yeGet(mapElem, "id")); return -1; }
void sdlResize(YWidgetState *wid, int renderType) { SDLWid *swid = wid->renderStates[renderType].opac; Entity *pos = yeGet(wid->entity, "pos"); swid->rect.h = yeGetInt(yeGet(pos, "h")) * WIN_H_SIZE / 1000; swid->rect.w = yeGetInt(yeGet(pos, "w")) * WIN_W_SIZE / 1000; swid->rect.x = yeGetInt(yeGet(pos, "x")) * WIN_W_SIZE / 1000; swid->rect.y = yeGetInt(yeGet(pos, "y")) * WIN_H_SIZE / 1000; }
void resize(YWidgetState *wid, int renderType) { CWidget *state = wid->renderStates[renderType].opac; Entity *pos = yeGet(wid->entity, "wid-pos"); state->h = yeGetInt(yeGet(pos, "h")) * LINES / 1000; state->w = yeGetInt(yeGet(pos, "w")) * COLS / 1000; state->x = yeGetInt(yeGet(pos, "x")) * COLS / 1000; state->y = yeGetInt(yeGet(pos, "y")) * LINES / 1000; wresize(state->win, state->h, state->w); mvwin(state->win, state->y, state->x); wborder(state->win, '|', '|', '-','-','+','+','+','+'); refresh(); }
void testLifeDeathRebirdAndAgain(void) { Entity *mainEnt = yeCreateArray(NULL, NULL); Entity *map; Entity *tmp; yeCreateInt(100, mainEnt, "width"); map = yeCreateArray(mainEnt, "map"); g_assert(map); for (int i = 0; i < 2000; ++i) { tmp = yeCreateArray(map, NULL); g_assert(tmp); g_assert(yeCreateInt(0, tmp, NULL)); } tmp = yeGet(map, 500); g_assert(tmp); yeCreateInt(1, tmp, "hr"); int good = 0;; for (int j = 500; j < 1000; ++j) { tmp = yeGet(map, j); for (unsigned int i = 0; i < yeLen(tmp); ++i) { Entity *curHero = yeGet(tmp, i); if (yeGetInt(curHero) == 1) { good = 1; /* You can get it Noww !!!! */ g_assert(yeLen(tmp) == 2); yeRemoveChild(tmp, curHero); g_assert(yeLen(tmp) == 1); break; } } } g_assert(good); YE_DESTROY(mainEnt); }
static int cursesRender(YWidgetState *state, int t) { CWidget *wid = ywidGetRenderData(state, t); int x,y,h,w; unsigned int curx = 0, cury = 0; Entity *map = yeGet(state->entity, "map"); Entity *res = ywMapGetResources(state); unsigned int lenMap = yeLen(map); unsigned int wMap = yeGetInt(yeGet(state->entity, "width")); unsigned int hMap = lenMap / wMap; wmove(wid->win,0,0); getyx(wid->win, y, x); getmaxyx(wid->win, h, w); w -= x; h -= y; for (unsigned int i = 0; i < lenMap; ++i) { Entity *mapCase = yeGet(map, i); if (curx >= wMap) { curx = 0; ++cury; } mvwaddch(wid->win, (cury + 1) + (h/2 - hMap / 2), (curx + 1) + (w/2 - wMap / 2), getPrintableChar(mapCase, res)); ++curx; } wrefresh(wid->win); return 0; }