static void _shutdown(void) { if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { ui_goodbye_title(); } else { ui_clear_win_title(); } } ui_close_all_wins(); jabber_disconnect(); jabber_shutdown(); roster_free(); muc_close(); caps_close(); ui_close(); #ifdef HAVE_LIBOTR otr_shutdown(); #endif #ifdef HAVE_LIBGPGME p_gpg_close(); #endif chat_log_close(); theme_close(); accounts_close(); tlscerts_close(); cmd_uninit(); log_stderr_close(); log_close(); prefs_close(); if (saved_status) { free(saved_status); } }
void atexit_handler() { config_close(); program_close(); ui_close(); states_clear(); dwindow_free(data.win[0]); dwindow_free(data.win[1]); }
//called at the end of the program void close_editor() { // _MARK_("end of editor");//Nuked to compile -KRB #ifndef __LINUX__ set_warn_func(msgbox_warning); #else clear_warn_func(NULL); #endif close_editor_screen(); //kill our camera object Viewer = ConsoleObject; //reset viewer //@@obj_delete(camera_objnum); padnum = ui_pad_get_current(); close_autosave(); ui_close(); gr_close_font(editor_font); PHYSFSX_removeRelFromSearchPath("editor/data"); PHYSFSX_removeRelFromSearchPath("editor"); PHYSFSX_removeRelFromSearchPath("editor.zip"); PHYSFSX_removeRelFromSearchPath("editor.dxa"); switch (ModeFlag) { case 1: if (Game_wind) window_close(Game_wind); break; case 2: if (Game_wind) window_close(Game_wind); set_screen_mode(SCREEN_MENU); //put up menu screen show_menus(); break; case 3: set_screen_mode(SCREEN_GAME); //put up game screen Game_mode = GM_EDITOR; editor_reset_stuff_on_level(); N_players = 1; break; } return; }
int main(int argc, char **argv) { char *paths[] = { NULL, NULL }; int i; pthread_t u_tid; cmdname = argv[0]; for (i = 1; i < argc && *argv[i] == '-'; i++) { if (streq(argv[i], "-h")) { usage(); } } paths[0] = (argc > i) ? argv[i] : "."; paths[1] = (argc > (i + 1)) ? argv[i + 1] : paths[0]; atexit(atexit_handler); if (!setlocale(LC_CTYPE, "")) die("couldn't set locale\n"); config_init(); program_init(); read_config_files(); /* setup windows */ for (i = 0; i < 2; i++) { data.win[i] = dwindow_create(); dwindow_set_sort(data.win[i], config()->sort); dwindow_read(data.win[i], paths[i]); } data.wsel = data.win[0]; /* setup ui */ ui_init(); theme_init(); /* set default state */ states_push(list_state()); /* start update thread */ pthread_mutex_init(&data.mutex, NULL); if (pthread_create(&u_tid, NULL, update_loop, &data) != 0) die("pthread_create: %s\n", strerror(errno)); main_loop(); ui_close(); return 0; }
void cmd_shell(struct wdata *data, const struct arg *arg) { char *shell = getenv("SHELL"); (void)arg; if (!shell) shell = "/bin/sh"; if (data->wsel->path) { ui_close(); chdir(data->wsel->path); system(shell); ui_init(); } }
static void _shutdown(void) { ui_clear_win_title(); ui_close_all_wins(); jabber_disconnect(); jabber_shutdown(); roster_free(); muc_close(); caps_close(); ui_close(); chat_log_close(); prefs_close(); theme_close(); accounts_close(); cmd_uninit(); log_close(); }
static void _shutdown(void) { if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { ui_goodbye_title(); } else { ui_clear_win_title(); } } jabber_conn_status_t conn_status = jabber_get_connection_status(); if (conn_status == JABBER_CONNECTED) { cl_ev_disconnect(); } #ifdef PROF_HAVE_GTK if (gtk_ready) { destroy_tray(); } #endif jabber_shutdown(); plugins_on_shutdown(); muc_close(); caps_close(); ui_close(); #ifdef PROF_HAVE_LIBOTR otr_shutdown(); #endif #ifdef PROF_HAVE_LIBGPGME p_gpg_close(); #endif chat_log_close(); theme_close(); accounts_close(); tlscerts_close(); cmd_uninit(); log_stderr_close(); log_close(); plugins_shutdown(); prefs_close(); if (saved_status) { free(saved_status); } }
static void _shutdown(void) { if (prefs_get_boolean(PREF_WINTITLE_SHOW)) { if (prefs_get_boolean(PREF_WINTITLE_GOODBYE)) { ui_goodbye_title(); } else { ui_clear_win_title(); } } jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { cl_ev_disconnect(); } #ifdef HAVE_GTK tray_shutdown(); #endif session_shutdown(); plugins_on_shutdown(); muc_close(); caps_close(); #ifdef HAVE_LIBOTR otr_shutdown(); #endif #ifdef HAVE_LIBGPGME p_gpg_close(); #endif chat_log_close(); theme_close(); accounts_close(); tlscerts_close(); log_stderr_close(); log_close(); plugins_shutdown(); cmd_uninit(); ui_close(); prefs_close(); }
// --------------------------------------------------------------------------------------------------- //this function is the editor. called when editor mode selected. runs until //game mode or exit selected void editor(void) { int w,h; grsBitmap * savedbitmap; editorView *new_cv; static int padnum=0; vmsMatrix MouseRotMat,tempm; //@@short camera_objnum; //a camera for viewing init_editor(); InitCurve(); RestoreEffectBitmapIcons(); if (!SetScreenMode(SCREEN_EDITOR)) { SetScreenMode(SCREEN_GAME); gameStates.app.nFunctionMode=FMODE_GAME; //force back into game return; } GrSetCurrentCanvas( NULL ); GrSetCurFont(editor_font); //Editor renders into full (320x200) game screen SetWarnFunc(med_show_warning); gameStates.input.keys.bRepeat = 1; // Allow repeat in editor // _MARK_("start of editor");//Nuked to compile -KRB ui_mouse_hide(); ui_reset_idleSeconds(); gameData.objs.viewer = gameData.objs.console; slew_init(gameData.objs.console); UpdateFlags = UF_ALL; medlisp_update_screen(); //set the wire-frame window to be the current view currentView = &LargeView; if (faded_in==0) { faded_in = 1; //gr_pal_fade_in( grdCurScreen->pal ); } w = GameViewBox->canvas->cvBitmap.bmProps.w; h = GameViewBox->canvas->cvBitmap.bmProps.h; savedbitmap = GrCreateBitmap(w, h ); GrBmUBitBlt( w, h, 0, 0, 0, 0, &GameViewBox->canvas->cvBitmap, savedbitmap ); GrSetCurrentCanvas( GameViewBox->canvas ); GrSetCurFont(editor_font); //GrSetColor( CBLACK ); //gr_deaccent_canvas(); //gr_grey_canvas(); ui_mouse_show(); GrSetCurFont(editor_font); ui_pad_goto(padnum); gamestate_restore_check(); while (gameStates.app.nFunctionMode == FMODE_EDITOR) { GrSetCurFont(editor_font); info_display_all(EditorWindow); ModeFlag = 0; // Update the windows // Only update if there is no key waiting and we're not in // fast play mode. if (!KeyPeekKey()) //-- && (MacroStatus != UI_STATUS_FASTPLAY)) medlisp_update_screen(); //do editor stuff GrSetCurFont(editor_font); ui_mega_process(); last_keypress &= ~KEYDBGGED; // mask off delete key bit which has no function in editor. ui_window_do_gadgets(EditorWindow); doRobot_window(); doObject_window(); do_wall_window(); do_trigger_window(); do_hostage_window(); do_centers_window(); check_wall_validity(); Assert(gameData.walls.nWalls>=0); if (Gameview_lockstep) { static tSegment *old_cursegp=NULL; static int old_curside=-1; if (old_cursegp!=Cursegp || old_curside!=Curside) { SetPlayerFromCursegMinusOne(); old_cursegp = Cursegp; old_curside = Curside; } } if ( ui_get_idleSeconds() > COMPRESS_INTERVAL ) { med_compress_mine(); ui_reset_idleSeconds(); } // Commented out because it occupies about 25% of time in twirling the mine. // Removes some Asserts.... // med_check_all_vertices(); clear_editor_status(); // if enough time elapsed, clear editor status message TimedAutosave(mine_filename); set_editorTime_of_day(); GrSetCurrentCanvas( GameViewBox->canvas ); // Remove keys used for slew switch(last_keypress) { case KEY_PAD9: case KEY_PAD7: case KEY_PADPLUS: case KEY_PADMINUS: case KEY_PAD8: case KEY_PAD2: case KEY_LBRACKET: case KEY_RBRACKET: case KEY_PAD1: case KEY_PAD3: case KEY_PAD6: case KEY_PAD4: last_keypress = 0; } if ((last_keypress&0xff)==KEY_LSHIFT) last_keypress=0; if ((last_keypress&0xff)==KEY_RSHIFT) last_keypress=0; if ((last_keypress&0xff)==KEY_LCTRL) last_keypress=0; if ((last_keypress&0xff)==KEY_RCTRL) last_keypress=0; // if ((last_keypress&0xff)==KEY_LALT) last_keypress=0; // if ((last_keypress&0xff)==KEY_RALT) last_keypress=0; GrSetCurFont(editor_font); menubar_do( last_keypress ); //=================== DO FUNCTIONS ==================== if ( KeyFunction[ last_keypress ] != NULL ) { KeyFunction[last_keypress](); last_keypress = 0; } switch (last_keypress) { case 0: case KEY_Z: case KEY_G: case KEY_LALT: case KEY_RALT: case KEY_LCTRL: case KEY_RCTRL: case KEY_LSHIFT: case KEY_RSHIFT: case KEY_LAPOSTRO: break; case KEY_SHIFTED + KEY_L: ToggleLighting(); break; case KEY_F1: render_3d_in_big_window = !render_3d_in_big_window; UpdateFlags |= UF_ALL; break; default: { char kdesc[100]; GetKeyDescription( kdesc, last_keypress ); editor_status("Error: %s isn't bound to anything.", kdesc ); } } //================================================================ if (ModeFlag==1) { close_editor_screen(); gameStates.app.nFunctionMode=FMODE_EXIT; GrFreeBitmap( savedbitmap ); break; } if (ModeFlag==2) //-- && MacroStatus==UI_STATUS_NORMAL ) { ui_mouse_hide(); gameStates.app.nFunctionMode = FMODE_GAME; GrBmUBitBlt( w, h, 0, 0, 0, 0, savedbitmap, &GameViewBox->canvas->cvBitmap); GrFreeBitmap( savedbitmap ); break; } if (ModeFlag==3) //-- && MacroStatus==UI_STATUS_NORMAL ) { // med_compress_mine(); //will be called anyways before game. close_editor_screen(); gameStates.app.nFunctionMode=FMODE_GAME; //force back into game SetScreenMode(SCREEN_GAME); //put up game screen GrFreeBitmap( savedbitmap ); break; } // if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) currentView=NULL; // if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) currentView=NULL; new_cv = currentView ; #if ORTHO_VIEWS if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox) new_cv=&TopView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView; if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)RightViewBox) new_cv=&RightView; #endif if (new_cv != currentView ) { currentView->ev_changed = 1; new_cv->ev_changed = 1; currentView = new_cv; } CalcFrameTime(); if (slew_frame(0)) { //do movement and check keys UpdateFlags |= UF_GAME_VIEW_CHANGED; if (Gameview_lockstep) { Cursegp = &gameData.segs.segments[gameData.objs.console->nSegment]; med_create_new_segment_from_cursegp(); UpdateFlags |= UF_ED_STATE_CHANGED; } } // DO TEXTURE STUFF texpage_do(); objpage_do(); // Process selection of Cursegp using mouse. if (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && !render_3d_in_big_window) { int xcrd,ycrd; xcrd = LargeViewBox->b1_drag_x1; ycrd = LargeViewBox->b1_drag_y1; find_segments(xcrd,ycrd,LargeViewBox->canvas,&LargeView,Cursegp,Big_depth); // Sets globals N_found_segs, Found_segs // If shift is down, then add tSegment to found list if (gameStates.input.keys.pressed[ KEY_LSHIFT ] || gameStates.input.keys.pressed[ KEY_RSHIFT ]) subtract_found_segments_from_selected_list(); else add_found_segments_to_selected_list(); Found_seg_index = 0; if (N_found_segs > 0) { sort_seg_list(N_found_segs,Found_segs,&gameData.objs.console->position.vPos); Cursegp = &gameData.segs.segments[Found_segs[0]]; med_create_new_segment_from_cursegp(); if (LockView_to_cursegp) setView_target_from_segment(Cursegp); } UpdateFlags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED; } if (GameViewBox->mouse_onme && GameViewBox->b1_dragging) { int x, y; x = GameViewBox->b1_drag_x2; y = GameViewBox->b1_drag_y2; ui_mouse_hide(); GrSetCurrentCanvas( GameViewBox->canvas ); GrSetColor( 15 ); GrRect( x-1, y-1, x+1, y+1 ); ui_mouse_show(); } // Set current tSegment and tSide by clicking on a polygon in game window. // If ctrl pressed, also assign current texture map to that tSide. //if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) { if ((GameViewBox->mouse_onme && GameViewBox->b1_clicked && !render_3d_in_big_window) || (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && render_3d_in_big_window)) { int xcrd,ycrd; int seg,tSide,face,poly,tmap; if (render_3d_in_big_window) { xcrd = LargeViewBox->b1_drag_x1; ycrd = LargeViewBox->b1_drag_y1; } else { xcrd = GameViewBox->b1_drag_x1; ycrd = GameViewBox->b1_drag_y1; } //Int3(); if (FindSegSideFace(xcrd,ycrd,&seg,&tSide,&face,&poly)) { if (seg<0) { //found an tObject CurObject_index = -seg-1; editor_status("Object %d selected.",CurObject_index); UpdateFlags |= UF_ED_STATE_CHANGED; } else { // See if either shift key is down and, if so, assign texture map if (gameStates.input.keys.pressed[KEY_LSHIFT] || gameStates.input.keys.pressed[KEY_RSHIFT]) { Cursegp = &gameData.segs.segments[seg]; Curside = tSide; AssignTexture(); med_create_new_segment_from_cursegp(); editor_status("Texture assigned"); } else if (gameStates.input.keys.pressed[KEY_G]) { tmap = gameData.segs.segments[seg].sides[tSide].nBaseTex; texpage_grab_current(tmap); editor_status( "Texture grabbed." ); } else if (gameStates.input.keys.pressed[ KEY_LAPOSTRO] ) { ui_mouse_hide(); moveObject_to_mouse_click(); } else { Cursegp = &gameData.segs.segments[seg]; Curside = tSide; med_create_new_segment_from_cursegp(); editor_status("Curseg and curside selected"); } } UpdateFlags |= UF_ED_STATE_CHANGED; } else editor_status("Click on non-texture ingored"); } // Allow specification of LargeView using mouse if (gameStates.input.keys.pressed[ KEY_LCTRL ] || gameStates.input.keys.pressed[ KEY_RCTRL ]) { ui_mouse_hide(); if ( (Mouse.dx!=0) && (Mouse.dy!=0) ) { GetMouseRotation( Mouse.dx, Mouse.dy, &MouseRotMat ); VmMatMul(&tempm,&LargeView.ev_matrix,&MouseRotMat); LargeView.ev_matrix = tempm; LargeView.ev_changed = 1; LargeView_index = -1; // say not one of the orthogonal views } } else { ui_mouse_show(); } if ( gameStates.input.keys.pressed[ KEY_Z ] ) { ui_mouse_hide(); if ( Mouse.dy!=0 ) { currentView->evDist += Mouse.dy*10000; currentView->ev_changed = 1; } } else { ui_mouse_show(); } } // _MARK_("end of editor");//Nuked to compile -KRB ClearWarnFunc(med_show_warning); //kill our camera tObject gameData.objs.viewer = gameData.objs.console; //reset viewer //@@ReleaseObject(camera_objnum); padnum = ui_pad_get_current(); close_editor(); ui_close(); }
int threads_linux_init(void) { int status = 0; int n = 0; int return_value = THREADS_LINUX_SUCCESS; // Init data status = sensors_init(&battery_data, &gps_data, &imu_data, &pitot_data, &pwm_read_data, &pwm_write_data, &scp1000_data, &sonar_data); if(status != SENSORS_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } if(return_value != THREADS_LINUX_FAILURE) { status = calibration_init(&calibration_local_coordinate_system_data, &calibration_local_fields_data, &calibration_altimeter_data); if(status != CALIBRATION_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = gps_init(&gps_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = imu_init(&imu_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = magnetometer_init(&magnetometer_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = sonar_init(&sonar_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = estimation_init(ESTIMATION_DO_NOT_ESTIMATE_ACCEL_BIAS, &estimation_data); if(status != ESTIMATION_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = control_init(&control_data); if(status != CONTROL_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = protocol_init(); if(status != PROTOCOL_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = ui_init(); if(status != UI_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } if(return_value != THREADS_LINUX_FAILURE) { status = datalogger_init(); if(status != DATALOGGER_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } } // Main Loop if(return_value != THREADS_LINUX_FAILURE) { threads_linux_timer_start_task_1(); usleep(0.5*task_1_period_us); threads_linux_timer_start_task_2(); usleep(5*task_1_period_us); while(quittask == 0) { #if ANU_COMPILE_FOR_OVERO #else if(datalogger_status() == DATALOGGER_RUNNING) datalogger_update_IPC(); #endif if(++n>100) { if(datalogger_status() == DATALOGGER_RUNNING) datalogger_write_file(); n = 0; } usleep(5*task_1_period_us); } threads_linux_timer_stop_task_1(); usleep(TASK1_PERIOD_US); threads_linux_timer_stop_task_2(); usleep(TASK2_PERIOD_US); } status = datalogger_close(); if(status != DATALOGGER_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = ui_close(); if(status != UI_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = protocol_close(); if(status != PROTOCOL_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = control_close(); if(status != CONTROL_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = estimation_close(&estimation_data); if(status != ESTIMATION_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = magnetometer_close(&magnetometer_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } status = imu_close(&imu_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } status = gps_close(&gps_measure); if(status != 1) { return_value = THREADS_LINUX_FAILURE; } status = calibration_close(&calibration_local_coordinate_system_data, &calibration_local_fields_data, &calibration_altimeter_data); if(status != CALIBRATION_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } status = sensors_close(); if(status != SENSORS_SUCCESS) { return_value = THREADS_LINUX_FAILURE; } return return_value; }
int main(void) { int status = 0; int n = 0; int return_value = SUCCESS; // Parameters for IMU and SPI imu_param.acc.full_res=1; imu_param.acc.rate=100; imu_param.acc.range=16; imu_param.gyr.rate=100; imu_param.gyr.lpf_bw=188; imu_param.gyr.clk_source='Z'; imu_param.gyr.act="XYZ"; imu_param.mag.rate=75; imu_param.mag.range=0; imu_param.mag.samples_avg=8; imu_param.mag.meas_mode=0; imu_param.mag.op_mode=0; spi_param.mode=0; spi_param.speed=375000; spi_param.cs=0; // printf("\ngpio186 inicialmente = %d\n",gpio_read(GPIO_S0)); //printf("gpio10 inicialmente = %d\n",gpio_read(GPIO_SHDN)); // Initialization if( devices_init(&imu_param, &spi_param, &mra_data)==FAILURE ) { perror("Unsuccesful devices initialization"); return -1; } if( datalogger_init()!=SUCCESS ) { perror("Unsuccesful datalogger initialization"); return -1; } if( ui_init() != SUCCESS) { perror("Unsuccesful user interface initialization"); return -1; } // enc_zero_set(enc_data)!=SUCCESS ? perror("Unsuccesfull encoder set zero "); return -1; //gpio_write(GPIO_S0,1); //mra_data.Out_0=2275; //actuate(spi_param.spi_dev,&mra_data); //return_value=FAILURE; // Main Loop if(return_value != FAILURE) { //datalogger_start(); timer_start_task_1(); usleep(0.5*task_1_period_us); timer_start_task_2(); usleep(5*task_1_period_us); while(quittask == 0) { #if ANU_COMPILE_FOR_OVERO #else //if(datalogger_status() == DATALOGGER_RUNNING) datalogger_update_IPC(); #endif if(++n>100) { //printf("n = %d\n",n); if(datalogger_status() == DATALOGGER_RUNNING) datalogger_write_file(); n = 0; } usleep(5*task_1_period_us); } datalogger_stop(); timer_stop_task_1(); usleep(TASK1_PERIOD_US); timer_stop_task_2(); usleep(TASK2_PERIOD_US); } status = datalogger_close(); if(status != DATALOGGER_SUCCESS) { return_value = FAILURE; } status = ui_close(); if(status != SUCCESS) { return_value = FAILURE; } devices_close(&imu_param, &spi_param, &mra_data); return return_value; }
bool ui_init() { movelist_init(); /* window, drawable stuff */ ui_display = XOpenDisplay(getenv("DISPLAY")); if (NULL == ui_display) { ui_close(); return false; } ui_rootwindow = DefaultRootWindow(ui_display); if (0 == ui_rootwindow) { ui_close(); return false; } ui_screenwidth = DisplayWidth(ui_display, DefaultScreen(ui_display)); ui_screenheight = DisplayHeight(ui_display, DefaultScreen(ui_display)); int depth = DisplayPlanes(ui_display, DefaultScreen(ui_display)); LOG( INFO, "Screen size: %dx%d, Depth: %d", ui_screenwidth, ui_screenheight, depth ); ui_backbuf = XCreatePixmap( ui_display, ui_rootwindow, ui_screenwidth, ui_screenheight, depth ); if ( ui_backbuf == 0 ) { ui_close(); return false; } ui_gcontext = XCreateGC(ui_display, ui_backbuf, 0, NULL); if (0 == ui_gcontext) { ui_close(); return false; } ui_xftdraw = XftDrawCreate(ui_display, ui_backbuf, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0)); if (NULL == ui_xftdraw) { ui_close(); return false; } /* load fonts */ ui_piecefont = XftFontOpen(ui_display, DefaultScreen(ui_display), XFT_FAMILY, XftTypeString, UI_FONT_FAMILY_PIECES, XFT_SIZE, XftTypeDouble, UI_FONT_SIZE_PIECES, NULL); if (NULL == ui_piecefont) { ui_close(); return false; } ui_infofont = XftFontOpen(ui_display, DefaultScreen(ui_display), XFT_FAMILY, XftTypeString, UI_FONT_FAMILY_TEXT, XFT_SIZE, XftTypeDouble, UI_FONT_SIZE_INFO, NULL); if (NULL == ui_infofont) { ui_close(); return false; } ui_namefont = XftFontOpen(ui_display, DefaultScreen(ui_display), XFT_FAMILY, XftTypeString, UI_FONT_FAMILY_TEXT, XFT_SIZE, XftTypeDouble, UI_FONT_SIZE_NAME, NULL); if (NULL == ui_namefont) { ui_close(); return false; } ui_coordfont = XftFontOpen(ui_display, DefaultScreen(ui_display), XFT_FAMILY, XftTypeString, UI_FONT_FAMILY_TEXT, XFT_SIZE, XftTypeDouble, UI_FONT_SIZE_COORD, XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD, NULL); if (NULL == ui_coordfont) { ui_close(); return false; } ui_infofontchwidth = ui_info_font_normal_char_width(); /* create colors */ XRenderColor whiteSquareColor; whiteSquareColor.red = (0xffff * ((UI_COL_WHITE_SQUARE >> 16) & 0xff)) / 0xff; whiteSquareColor.green = (0xffff * ((UI_COL_WHITE_SQUARE >> 8) & 0xff)) / 0xff; whiteSquareColor.blue = (0xffff * (UI_COL_WHITE_SQUARE & 0xff)) / 0xff; whiteSquareColor.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &whiteSquareColor, &ui_squarecolorwhite)) { ui_squarecolorwhiteinit = false; ui_close(); return false; } ui_squarecolorwhiteinit = true; XRenderColor blackSquareColor; blackSquareColor.red = (0xffff * ((UI_COL_BLACK_SQUARE >> 16) & 0xff)) / 0xff; blackSquareColor.green = (0xffff * ((UI_COL_BLACK_SQUARE >> 8) & 0xff)) / 0xff; blackSquareColor.blue = (0xffff * (UI_COL_BLACK_SQUARE & 0xff)) / 0xff; blackSquareColor.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &blackSquareColor, &ui_squarecolorblack)) { ui_squarecolorblackinit = false; ui_close(); return false; } ui_squarecolorblackinit = true; XRenderColor white; white.red = 0xffff; white.green = 0xffff; white.blue = 0xffff; white.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &white, &ui_piececolorwhite)) { ui_piececolorwhiteinit = false; ui_close(); return false; } ui_piececolorwhiteinit = true; XRenderColor black; black.red = 0; black.green = 0; black.blue = 0; black.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &black, &ui_piececolorblack)) { ui_piececolorblackinit = false; ui_close(); return false; } ui_piececolorblackinit = true; XRenderColor infocolor; infocolor.red = 0x6666; infocolor.green = 0x6666; infocolor.blue = 0x6666; infocolor.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &infocolor, &ui_infocolor)) { ui_infocolorinit = false; ui_close(); return false; } ui_infocolorinit = true; XRenderColor infocolortag; infocolortag.red = 0x4444; infocolortag.green = 0x4444; infocolortag.blue = 0x4444; infocolortag.alpha = 0xffff; if (!XftColorAllocValue(ui_display, DefaultVisual(ui_display, 0), DefaultColormap(ui_display, 0), &infocolortag, &ui_infocolortag)) { ui_infocolortaginit = false; ui_close(); return false; } ui_infocolortaginit = true; /* start with board on the left */ ui_board_pos_x = UI_POS_BOARD_X_LEFT; return true; }