static void xaw_key_open_messages(Widget w, XEvent *event, String *argv, Cardinal *argc) { if (can_client_change_view() && is_menu_item_active(MENU_REPORT, MENU_REPORT_MESSAGES)) { meswin_dialog_popup(FALSE); } }
/************************************************************************** ... **************************************************************************/ static void show_main_page(void) { SDL_Color bg_color = {255, 255, 255, 96}; SDL_Color *line_color = &(SDL_Color) { 128, 128, 128, 255 }; int count = 0; struct widget *pWidget = NULL, *pWindow = NULL; SDL_Surface *pBackground; int h = 0; SDL_Rect area; char verbuf[200]; /* create dialog */ pStartMenu = fc_calloc(1, sizeof(struct SMALL_DLG)); pWindow = create_window_skeleton(NULL, NULL, 0); add_to_gui_list(ID_WINDOW, pWindow); pStartMenu->pEndWidgetList = pWindow; area = pWindow->area; /* Freeciv version */ /* TRANS: Freeciv 2.4.0, gui-sdl client */ fc_snprintf(verbuf, sizeof(verbuf), _("Freeciv %s, %s client"), VERSION_STRING, client_string); pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, verbuf, adj_font(12), (WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pWidget->string16->style |= SF_CENTER | TTF_STYLE_BOLD; area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; add_to_gui_list(ID_LABEL, pWidget); /* Start New Game */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Start New Game"), adj_font(14), (WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pWidget->action = start_new_game_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; add_to_gui_list(ID_START_NEW_GAME, pWidget); /* Load Game */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Load Game"), adj_font(14), (WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND)); pWidget->action = load_game_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_LOAD_GAME, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; /* Join Game */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join Game"), adj_font(14), WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = join_game_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_JOIN_GAME, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; /* Join Pubserver */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join Pubserver"), adj_font(14), WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = servers_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_JOIN_META_GAME, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; /* Join LAN Server */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join LAN Server"), adj_font(14), WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = servers_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_JOIN_GAME, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; /* Options */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Options"), adj_font(14), WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = options_callback; pWidget->string16->style |= SF_CENTER; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_CLIENT_OPTIONS_BUTTON, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; /* Quit */ pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Quit"), adj_font(14), WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = quit_callback; pWidget->string16->style |= SF_CENTER; pWidget->key = SDLK_ESCAPE; set_wstate(pWidget, FC_WS_NORMAL); add_to_gui_list(ID_QUIT, pWidget); area.w = MAX(area.w, pWidget->size.w); h = MAX(h, pWidget->size.h); count++; pStartMenu->pBeginWidgetList = pWidget; /* ------*/ area.w += adj_size(30); h += adj_size(6); area.h = MAX(area.h, h * count); /* ------*/ pBackground = theme_get_background(theme, BACKGROUND_STARTMENU); if (resize_window(pWindow, pBackground, NULL, (pWindow->size.w - pWindow->area.w) + area.w, (pWindow->size.h - pWindow->area.h) + area.h)) { FREESURFACE(pBackground); } area = pWindow->area; group_set_area(pWidget, pWindow->prev, area); setup_vertical_widgets_position(1, area.x, area.y, area.w, h, pWidget, pWindow->prev); area.h = h; SDL_FillRectAlpha(pWindow->theme, &area, &bg_color); widget_set_position(pWindow, (Main.screen->w - pWindow->size.w) - adj_size(20), (Main.screen->h - pWindow->size.h) - adj_size(20)); draw_intro_gfx(); redraw_group(pStartMenu->pBeginWidgetList, pStartMenu->pEndWidgetList, FALSE); putline(pWindow->dst->surface, area.x, area.y + (h - 1), area.x + area.w - 1, area.y + (h - 1), line_color); set_output_window_text(_("SDLClient welcomes you...")); chat_welcome_message(); meswin_dialog_popup(TRUE); flush_all(); }
/************************************************************************** Main handler for key presses **************************************************************************/ static Uint16 main_key_down_handler(SDL_keysym Key, void *pData) { static struct widget *pWidget; if ((pWidget = find_next_widget_for_key(NULL, Key)) != NULL) { return widget_pressed_action(pWidget); } else { if (Key.sym == SDLK_TAB) { /* input */ popup_input_line(); } else { if (map_event_handler(Key) && C_S_RUNNING == client_state()) { switch (Key.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: if (LSHIFT || RSHIFT) { disable_focus_animation(); key_end_turn(); } else { struct unit *pUnit; struct city *pCity; if (NULL != (pUnit = head_of_units_in_focus()) && (pCity = tile_city(unit_tile(pUnit))) != NULL && city_owner(pCity) == client.conn.playing) { popup_city_dialog(pCity); } } return ID_ERROR; case SDLK_F2: units_report_dialog_popup(FALSE); return ID_ERROR; case SDLK_F4: city_report_dialog_popup(FALSE); return ID_ERROR; case SDLK_F7: send_report_request(REPORT_WONDERS_OF_THE_WORLD); return ID_ERROR; case SDLK_F8: send_report_request(REPORT_TOP_5_CITIES); return ID_ERROR; case SDLK_F9: if (meswin_dialog_is_open()) { meswin_dialog_popdown(); } else { meswin_dialog_popup(TRUE); } flush_dirty(); return ID_ERROR; case SDLK_F11: send_report_request(REPORT_DEMOGRAPHIC); return ID_ERROR; case SDLK_F12: popup_spaceship_dialog(client.conn.playing); return ID_ERROR; default: return ID_ERROR; } } } } return ID_ERROR; }