Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #904745 ยป 0036-sdl2-Rename-p-List-to-adhere-coding-style.patch

Marko Lindqvist, 2020-12-09 10:36 PM

View differences:

client/gui-sdl2/citydlg.c
207 pixels is panel width in city dlg.
220 - max y position pixel position belong to panel area.
**************************************************************************/
static void create_present_supported_units_widget_list(struct unit_list *pList)
static void create_present_supported_units_widget_list(struct unit_list *units)
{
int i;
struct widget *buf = NULL;
......
h = tileset_full_tile_height(tileset) + (adj_size(151) % (tileset_full_tile_height(tileset)+4)) / num_y;
}
unit_list_iterate(pList, punit) {
unit_list_iterate(units, punit) {
const char *vetname;
putype = unit_type_get(punit);
......
utf8_str *pstr;
SDL_Surface *surf;
SDL_Rect dest;
struct unit_list *pList;
struct unit_list *units;
int size;
if (city_owner(pcity_dlg->pcity) != client.conn.playing) {
pList = (pcity_dlg->pcity->client.info_units_supported);
units = (pcity_dlg->pcity->client.info_units_supported);
} else {
pList = (pcity_dlg->pcity->units_supported);
units = (pcity_dlg->pcity->units_supported);
}
size = unit_list_size(pList);
size = unit_list_size(units);
fc_snprintf(cbuf, sizeof(cbuf), _("Supported units: %d"), size);
......
}
} else {
if (size > 0) {
create_present_supported_units_widget_list(pList);
create_present_supported_units_widget_list(units);
redraw_group(pcity_dlg->pPanel->begin_widget_list,
pcity_dlg->pPanel->end_widget_list, 0);
}
......
utf8_str *pstr;
SDL_Surface *surf;
SDL_Rect dest;
struct unit_list *pList;
struct unit_list *units;
int size;
if (city_owner(pcity_dlg->pcity) != client.conn.playing) {
pList = pcity_dlg->pcity->client.info_units_present;
units = pcity_dlg->pcity->client.info_units_present;
} else {
pList = pcity_dlg->pcity->tile->units;
units = pcity_dlg->pcity->tile->units;
}
size = unit_list_size(pList);
size = unit_list_size(units);
fc_snprintf(cbuf, sizeof(cbuf), _("Present units: %d"), size);
......
}
} else {
if (size) {
create_present_supported_units_widget_list(pList);
create_present_supported_units_widget_list(units);
redraw_group(pcity_dlg->pPanel->begin_widget_list,
pcity_dlg->pPanel->end_widget_list, 0);
}
client/gui-sdl2/widget.c
}
/**********************************************************************//**
Find ID in Widget's List ('pGUI_List') and return pointer to this
Find ID in Widget's List ('gui_list') and return pointer to this
Widget.
**************************************************************************/
struct widget *get_widget_pointer_form_ID(const struct widget *pGUI_List,
struct widget *get_widget_pointer_form_ID(const struct widget *gui_list,
Uint16 id, enum scan_direction direction)
{
while (pGUI_List) {
if (pGUI_List->id == id) {
return (struct widget *) pGUI_List;
while (gui_list) {
if (gui_list->id == id) {
return (struct widget *) gui_list;
}
if (direction == SCAN_FORWARD) {
pGUI_List = pGUI_List->next;
gui_list = gui_list->next;
} else {
pGUI_List = pGUI_List->prev;
gui_list = gui_list->prev;
}
}
......
}
/**********************************************************************//**
Delete Wideget's List ('pGUI_List').
Delete Wideget's List ('gui_list').
**************************************************************************/
void del_gui_list(struct widget *pGUI_List)
void del_gui_list(struct widget *gui_list)
{
while (pGUI_List) {
if (pGUI_List->next) {
pGUI_List = pGUI_List->next;
FREEWIDGET(pGUI_List->prev);
while (gui_list) {
if (gui_list->next) {
gui_list = gui_list->next;
FREEWIDGET(gui_list->prev);
} else {
FREEWIDGET(pGUI_List);
FREEWIDGET(gui_list);
}
}
}
client/gui-sdl2/widget.h
bool is_this_widget_first_on_list(struct widget *pGUI);
void move_widget_to_front_of_gui_list(struct widget *pGUI);
void del_gui_list(struct widget *pGUI_List);
void del_gui_list(struct widget *gui_list);
void del_main_list(void);
struct widget *find_next_widget_at_pos(struct widget *start_widget, int x, int y);
struct widget *find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key);
struct widget *get_widget_pointer_form_ID(const struct widget *pGUI_List,
struct widget *get_widget_pointer_form_ID(const struct widget *gui_list,
Uint16 id,
enum scan_direction direction);
client/gui-sdl2/wldlg.c
/* shortcuts */
struct widget *dock;
struct widget *pWorkList_Counter;
struct widget *worklist_counter;
struct widget *pProduction_Name;
struct widget *pProduction_Progres;
......
{
struct global_worklist *pGWL = global_worklist_by_id(MAX_ID - pwidget->id);
struct widget *buf = editor->pWork->end_active_widget_list;
const struct worklist *pWorkList;
const struct worklist *pworklist;
int count, firstfree;
if (!pGWL
|| !(pWorkList = global_worklist_get(pGWL))
|| worklist_is_empty(pWorkList)) {
|| !(pworklist = global_worklist_get(pGWL))
|| worklist_is_empty(pworklist)) {
return;
}
......
firstfree = worklist_length(&editor->worklist_copy);
/* copy global worklist to city worklist */
for (count = 0 ; count < worklist_length(pWorkList); count++) {
for (count = 0 ; count < worklist_length(pworklist); count++) {
/* global worklist can have targets unavilable in current state of game
then we must remove those targets from new city worklist */
if (!can_city_build_later(editor->pcity, &pWorkList->entries[count])) {
if (!can_city_build_later(editor->pcity, &pworklist->entries[count])) {
continue;
}
worklist_append(&editor->worklist_copy, &pWorkList->entries[count]);
worklist_append(&editor->worklist_copy, &pworklist->entries[count]);
/* create widget */
if (VUT_UTYPE == pWorkList->entries[count].kind) {
if (VUT_UTYPE == pworklist->entries[count].kind) {
buf = create_iconlabel(NULL, pwidget->dst,
create_utf8_from_char(
utype_name_translation(pWorkList->entries[count].value.utype),
utype_name_translation(pworklist->entries[count].value.utype),
adj_font(10)),
(WF_RESTORE_BACKGROUND|WF_FREE_DATA));
buf->id = MAX_ID - cid_encode_unit(pWorkList->entries[count].value.utype);
buf->id = MAX_ID - cid_encode_unit(pworklist->entries[count].value.utype);
} else {
buf = create_iconlabel(NULL, pwidget->dst,
create_utf8_from_char(
city_improvement_name_translation(editor->pcity,
pWorkList->entries[count].value.building),
pworklist->entries[count].value.building),
adj_font(10)),
(WF_RESTORE_BACKGROUND|WF_FREE_DATA));
buf->id = MAX_ID - cid_encode_building(pWorkList->entries[count].value.building);
buf->id = MAX_ID - cid_encode_building(pworklist->entries[count].value.building);
}
buf->string_utf8->style |= SF_CENTER;
......
{
struct global_worklist *pGWL = global_worklist_by_id(MAX_ID - pwidget->id);
struct widget *buf = editor->pWork->end_active_widget_list;
const struct worklist *pWorkList;
const struct worklist *pworklist;
struct worklist wl;
int count, wl_count;
struct universal target;
if (!pGWL
|| !(pWorkList = global_worklist_get(pGWL))
|| worklist_is_empty(pWorkList)) {
|| !(pworklist = global_worklist_get(pGWL))
|| worklist_is_empty(pworklist)) {
return;
}
......
wl_count = 0;
/* copy global worklist to city worklist */
for (count = 0; count < worklist_length(pWorkList); count++) {
for (count = 0; count < worklist_length(pworklist); count++) {
/* global worklist can have targets unavilable in current state of game
then we must remove those targets from new city worklist */
if (!can_city_build_later(editor->pcity, &pWorkList->entries[count])) {
if (!can_city_build_later(editor->pcity, &pworklist->entries[count])) {
continue;
}
wl.entries[wl_count] = pWorkList->entries[count];
wl.entries[wl_count] = pworklist->entries[count];
wl_count++;
}
/* --------------------------------- */
......
fc_snprintf(cbuf, sizeof(cbuf),
/* TRANS: length of worklist */
PL_("( %d entry )", "( %d entries )", len), len);
copy_chars_to_utf8_str(editor->pWorkList_Counter->string_utf8, cbuf);
copy_chars_to_utf8_str(editor->worklist_counter->string_utf8, cbuf);
widget_undraw(editor->pWorkList_Counter);
remake_label_size(editor->pWorkList_Counter);
widget_undraw(editor->worklist_counter);
remake_label_size(editor->worklist_counter);
editor->pWorkList_Counter->size.x = editor->end_widget_list->area.x +
(adj_size(130) - editor->pWorkList_Counter->size.w)/2;
editor->worklist_counter->size.x = editor->end_widget_list->area.x +
(adj_size(130) - editor->worklist_counter->size.w)/2;
if (get_wflags(editor->pWorkList_Counter) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(editor->pWorkList_Counter);
if (get_wflags(editor->worklist_counter) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(editor->worklist_counter);
}
widget_redraw(editor->pWorkList_Counter);
widget_redraw(editor->worklist_counter);
/* Can't just widget_mark_dirty(), as it may have reduced in size */
area.x = editor->end_widget_list->area.x; /* left edge of client area */
area.y = editor->pWorkList_Counter->size.y;
area.y = editor->worklist_counter->size.y;
area.w = adj_size(130);
area.h = editor->pWorkList_Counter->size.h;
area.h = editor->worklist_counter->size.h;
layer_rect_to_screen_rect(editor->end_widget_list->dst, &area);
dirty_sdl_rect(&area);
}
......
pstr = create_utf8_from_char(cbuf, adj_font(10));
pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
editor->pWorkList_Counter = buf;
editor->worklist_counter = buf;
add_to_gui_list(ID_LABEL, buf);
/* --------------------------- */
    (1-1/1)