static void *obs_x264_create(obs_data_t *settings, obs_encoder_t *encoder) { struct obs_x264 *obsx264 = bzalloc(sizeof(struct obs_x264)); obsx264->encoder = encoder; if (update_settings(obsx264, settings)) { obsx264->context = x264_encoder_open(&obsx264->params); if (obsx264->context == NULL) warn("x264 failed to load"); else load_headers(obsx264); } else { warn("bad settings specified"); } if (!obsx264->context) { bfree(obsx264); return NULL; } obsx264->performance_token = os_request_high_performance("x264 encoding"); return obsx264; }
bool DayWatcherThread::run() { Log.Notice("DayWatcherThread", "Started."); currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); load_settings(); set_tm_pointers(); m_busy = false; #ifdef WIN32 m_abortEvent = CreateEvent(NULL, NULL, FALSE, NULL); #else struct timeval now; struct timespec tv; pthread_mutex_init(&abortmutex,NULL); pthread_cond_init(&abortcond,NULL); #endif while(ThreadState != THREADSTATE_TERMINATE) { m_busy=true; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); if(has_timeout_expired(&local_currenttime, &local_last_arena_time, arena_period)) update_arena(); if(has_timeout_expired(&local_currenttime, &local_last_daily_time, daily_period)) update_daily(); if(m_dirty) update_settings(); m_busy=false; if(ThreadState == THREADSTATE_TERMINATE) break; #ifdef WIN32 if (m_abortEvent) WaitForSingleObject(m_abortEvent, THREAD_LOOP_INTERVAL*1000); #else gettimeofday(&now, NULL); tv.tv_sec = now.tv_sec + THREAD_LOOP_INTERVAL; tv.tv_nsec = now.tv_usec * 1000; pthread_mutex_lock(&abortmutex); pthread_cond_timedwait(&abortcond, &abortmutex, &tv); pthread_mutex_unlock(&abortmutex); #endif if(!m_running) break; } #ifdef WIN32 if (m_abortEvent) CloseHandle(m_abortEvent); #else pthread_mutex_destroy(&abortmutex); pthread_cond_destroy(&abortcond); #endif return true; }
void initialize(u32int fg, u32int bg) { // Initialization calls update_settings(fg,bg); monitor_clear(); init_descriptor_tables(); asm("sti"); init_keyboard(); init_timer(1000); }
static void *obs_qsv_create(obs_data_t *settings, obs_encoder_t *encoder) { InitializeCriticalSection(&g_QsvCs); struct obs_qsv *obsqsv = bzalloc(sizeof(struct obs_qsv)); obsqsv->encoder = encoder; if (update_settings(obsqsv, settings)) { EnterCriticalSection(&g_QsvCs); obsqsv->context = qsv_encoder_open(&obsqsv->params); LeaveCriticalSection(&g_QsvCs); if (obsqsv->context == NULL) warn("qsv failed to load"); else load_headers(obsqsv); } else { warn("bad settings specified"); } qsv_encoder_version(&g_verMajor, &g_verMinor); blog(LOG_INFO, "\tmajor: %d\n" "\tminor: %d", g_verMajor, g_verMinor); // MSDK 1.6 or less doesn't have automatic DTS calculation // including early SandyBridge. // Need to add manual DTS from PTS. if (g_verMajor == 1 && g_verMinor < 7) { int64_t interval = obsqsv->params.nbFrames + 1; int64_t GopPicSize = (int64_t)(obsqsv->params.nKeyIntSec * obsqsv->params.nFpsNum / (float)obsqsv->params.nFpsDen); g_pts2dtsShift = GopPicSize - (GopPicSize / interval) * interval; blog(LOG_INFO, "\tinterval: %d\n" "\tGopPictSize: %d\n" "\tg_pts2dtsShift: %d", interval, GopPicSize, g_pts2dtsShift); } else g_pts2dtsShift = -1; if (!obsqsv->context) { bfree(obsqsv); return NULL; } obsqsv->performance_token = os_request_high_performance("qsv encoding"); g_bFirst = true; return obsqsv; }
static void destroy_cb (GtkWidget *widget, DialogData *data) { update_settings (data); g_object_unref (data->builder); g_object_unref (data->settings); g_free (data); }
static void *monitor_capture_create(obs_data_t *settings, obs_source_t *source) { struct monitor_capture *capture; capture = bzalloc(sizeof(struct monitor_capture)); capture->source = source; update_settings(capture, settings); return capture; }
void BlockBase::pressedApply(QAbstractButton *origin) { if(origin->text()=="Apply"){ char name[50]; sprintf(name,"%s",d_name.toStdString().c_str()); if(update_settings(name)){ errorMessage("pressedOk","Unable to save settings.",this); } } }
static void inbox_received_handler(DictionaryIterator *iterator, void *context) { // Get tuple Tuple *t = dict_read_first(iterator); while (t != NULL) { switch (t->key) { case KEY_COLOR_TEXT: persist_write_int(KEY_COLOR_TEXT, t->value->int32); break; case KEY_COLOR_INDICATOR: persist_write_int(KEY_COLOR_INDICATOR, t->value->int32); break; case KEY_COLOR_RING_1: persist_write_int(KEY_COLOR_RING_1, t->value->int32); break; case KEY_COLOR_RING_2: persist_write_int(KEY_COLOR_RING_2, t->value->int32); break; case KEY_COLOR_BG_IN: persist_write_int(KEY_COLOR_BG_IN, t->value->int32); break; case KEY_COLOR_BG_OUT: persist_write_int(KEY_COLOR_BG_OUT, t->value->int32); break; case KEY_SHOW_DAY: if (strcmp(t->value->cstring, "true") == 0) { persist_write_bool(KEY_SHOW_DAY, true); } else if (strcmp(t->value->cstring, "false") == 0) { persist_write_bool(KEY_SHOW_DAY, false); } break; case KEY_SHOW_DATE: if (strcmp(t->value->cstring, "true") == 0) { persist_write_bool(KEY_SHOW_DATE, true); } else if (strcmp(t->value->cstring, "false") == 0) { persist_write_bool(KEY_SHOW_DATE, false); } break; case KEY_VIBE_BT: if (strcmp(t->value->cstring, "true") == 0) { persist_write_bool(KEY_VIBE_BT, true); } else if (strcmp(t->value->cstring, "false") == 0) { persist_write_bool(KEY_VIBE_BT, false); } break; } // Get next pair, if any t = dict_read_next(iterator); } update_settings(); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); update_settings(); window_set_background_color(window, INVERT_COLOURS ? GColorWhite : GColorBlack); hours_layer = create_arc_layer(window_layer, bounds, hours_layer, &(Arc) { .percent = 0, .radius = 40 });
FormOptimization::FormOptimization(ThreadRunner& thread, QSettings& settings, XMLableDB<Qpx::Detector>& detectors, QWidget *parent) : QWidget(parent), ui(new Ui::FormOptimization), opt_runner_thread_(thread), settings_(settings), detectors_(detectors), interruptor_(false), opt_plot_thread_(current_spectra_), my_run_(false) { ui->setupUi(this); this->setWindowTitle("Optimization"); //loadSettings(); connect(&opt_runner_thread_, SIGNAL(runComplete()), this, SLOT(run_completed())); if (Qpx::Spectrum::Template *temp = Qpx::Spectrum::Factory::getInstance().create_template("1D")) { optimizing_ = *temp; delete temp; } optimizing_.name_ = "Optimizing"; optimizing_.visible = true; style_pts.default_pen = QPen(Qt::darkBlue, 7); style_pts.themes["selected"] = QPen(Qt::red, 7); ui->plotSpectrum->setFit(&fitter_opt_); //connect(ui->plotSpectrum, SIGNAL(peaks_changed(bool)), this, SLOT(update_peaks(bool))); ui->PlotCalib->setLabels("setting", "FWHM"); ui->tableResults->setColumnCount(5); ui->tableResults->setHorizontalHeaderItem(0, new QTableWidgetItem("Setting value", QTableWidgetItem::Type)); ui->tableResults->setHorizontalHeaderItem(1, new QTableWidgetItem("Energy", QTableWidgetItem::Type)); ui->tableResults->setHorizontalHeaderItem(2, new QTableWidgetItem("FWHM", QTableWidgetItem::Type)); ui->tableResults->setHorizontalHeaderItem(3, new QTableWidgetItem("area", QTableWidgetItem::Type)); ui->tableResults->setHorizontalHeaderItem(4, new QTableWidgetItem("%error", QTableWidgetItem::Type)); ui->tableResults->setSelectionBehavior(QAbstractItemView::SelectRows); ui->tableResults->setSelectionMode(QAbstractItemView::SingleSelection); ui->tableResults->horizontalHeader()->setStretchLastSection(true); ui->tableResults->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); connect(ui->tableResults, SIGNAL(itemSelectionChanged()), this, SLOT(resultChosen())); connect(&opt_plot_thread_, SIGNAL(plot_ready()), this, SLOT(update_plots())); loadSettings(); update_settings(); opt_plot_thread_.start(); }
static void *monitor_capture_create(obs_data_t settings, obs_source_t source) { struct monitor_capture *capture; effect_t opaque_effect = create_opaque_effect(); if (!opaque_effect) return NULL; capture = bzalloc(sizeof(struct monitor_capture)); capture->opaque_effect = opaque_effect; update_settings(capture, settings); return capture; }
static bool obs_x264_update(void *data, obs_data_t *settings) { struct obs_x264 *obsx264 = data; bool success = update_settings(obsx264, settings); int ret; if (success) { ret = x264_encoder_reconfig(obsx264->context, &obsx264->params); if (ret != 0) warn("Failed to reconfigure: %d", ret); return ret == 0; } return false; }
gh_game::gh_game (string config) { GH_FUNCTION() // // This is a hack so the main loop can dump messages without the game // class present. Don't use this if you can. // gh_global::game = this; frame = 0; player = NULL; level_set_name = "random"; level_no = 1; which_level = "dummy"; new_player_name = ""; new_player_class = ""; hiscores = NULL; level_maps = NULL; res = GH_RES; paused = false; help_screen = false; quit_screen = false; info_screen = false; want_to_enter_level_editor_mode = false; want_to_exit_level_editor_mode = false; help_message = false; full_moon_message = false; midnight_message = false; friday_13th_message = false; halloween_message = false; dark_message = false; try { if (config != "") { gh_read_file(this, config, true, /* noisy */ true /* error */); } } catch (...) { gh_global::fullscreen = true; gh_global::noframe = true; } update_settings(); level_maps = new gh_level_maps(); }
DisplayFltkMenu::DisplayFltkMenu(VMDApp *anApp) : VMDFltkMenu("display", "Display Settings", anApp) { make_window(); update_settings(); command_wanted(Command::DISP_EYESEP); command_wanted(Command::DISP_FOCALLEN); command_wanted(Command::DISP_CLIP); command_wanted(Command::DISP_SCRHEIGHT); command_wanted(Command::DISP_SCRDIST); command_wanted(Command::DISP_CUEMODE); command_wanted(Command::DISP_CUESTART); command_wanted(Command::DISP_CUEEND); command_wanted(Command::DISP_CUEDENSITY); command_wanted(Command::DISP_AO); command_wanted(Command::DISP_AO_AMBIENT); command_wanted(Command::DISP_AO_DIRECT); }
LIRenAttachmentParticle::LIRenAttachmentParticle (LIRenObject* object, const Ogre::String& particle) : LIRenAttachment (object) { particles = NULL; try { // Attach a new particle system to the scene node. Ogre::String e_name = render->id.next (); particles = render->scene_manager->createParticleSystem (e_name, particle); object->node->attachObject (particles); // Set particle effect visibility. particles->setVisible (object->get_visible ()); // Apply settings. update_settings (); } catch (...) { } }
static bool obs_qsv_update(void *data, obs_data_t *settings) { struct obs_qsv *obsqsv = data; bool success = update_settings(obsqsv, settings); int ret; if (success) { EnterCriticalSection(&g_QsvCs); ret = qsv_encoder_reconfig(obsqsv->context, &obsqsv->params); if (ret != 0) warn("Failed to reconfigure: %d", ret); LeaveCriticalSection(&g_QsvCs); return ret == 0; } return false; }
void settings_cb(GtkButton *button, GtkWindow *window) { GtkWidget *dialog; GArray *items; int result; dialog = gtk_dialog_new_with_buttons("Settings", window, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); items = create_settings_dialog(dialog); gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { update_settings(items); update_source_views(); save_program_settings(); } gtk_widget_destroy(dialog); }
CameraControl::CameraControl(TempSettings *gamesettings){ if (gamesettings == NULL){ std::cerr << "A null pointer was passed into camera control\n"; return; } name = "camera"; planeZs.push_back(0); planeZs.push_back(10); planeZs.push_back(1); zoomin_speed = 0.05; zoomout_speed = 0.075; zoom_friction = 0.3; momentum_on = true; sidebuffer = 0.5; pan_speed = 0.25; dx = 0; dy = 0; dz = 0; mouse_control = false; fieldofview_w = 75*3.14156/180.0; tanfov_w = tan(fieldofview_w/2.0); pixelratio.push_back(1000); pixelratio.push_back(500); pixelratio.push_back(1); xtracking = NULL; ytracking = NULL; game_settings = gamesettings; gamesettings->addToList(this); update_settings(); }
bool DayWatcherThread::run() { Log.Success("DayWatcherThread", "Started."); currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); load_settings(); set_tm_pointers(); m_busy = false; while (GetThreadState() != THREADSTATE_TERMINATE) { m_busy = true; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); if (has_timeout_expired(&local_currenttime, &local_last_arena_time, arena_period)) update_arena(); if (has_timeout_expired(&local_currenttime, &local_last_daily_time, daily_period)) update_daily(); if (m_dirty) update_settings(); m_busy = false; if (GetThreadState() == THREADSTATE_TERMINATE) break; cond.Wait(THREAD_LOOP_INTERVAL * 1000); if (!m_running) break; } return true; }
std::string CameraControl::parse_arguments(std::vector<std::string> args){ if (args[0].compare(name) != 0) return ""; std::stringstream returnstring; if (args[1].compare("help") == 0){ returnstring << "Possilble camera commands are:\n"; returnstring << " camera help\n"; returnstring << " camera camx <double>\n"; returnstring << " camera camy <double>\n"; returnstring << " camera camz <double>\n"; returnstring << " camera camyaw <double>\n"; returnstring << " camera zoomin_speed <double>\n"; returnstring << " camera zoomout_speed <double>\n"; returnstring << " camera zoom_friction <double>\n"; returnstring << " camera momentum_on <true/false>\n"; returnstring << " camera sidebuffer <double>\n"; returnstring << " camera pan_speed <double>\n"; returnstring << " camera fieldofvew <double>\n"; returnstring << " camera planeZs <Floor/Player> <double>\n"; returnstring << " camera <command> ?\n\n"; returnstring << " camera <command> help\n\n"; } else if (args[1].compare("camx") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera camx <double>\n"; returnstring << " Sets the new camera x position. It is bounded by map width and field of view.\n\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera camx " << camx << std::endl; } else{ camx = atof(args[2].c_str()); checkcamxy(); returnstring << "camx set to " << camx << std::endl; } } else if (args[1].compare("camy") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera camy <double>\n"; returnstring << " Sets the new camera y position. It is bounded by map height and field of view.\n\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera camy " << camy << std::endl; } else{ camy = atof(args[2].c_str()); checkcamxy(); returnstring << "camy set to " << camy << std::endl; } } else if (args[1].compare("camz") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera camz <double>\n"; returnstring << " Sets the new camera z position. It is bounded by map size and field of view (a pyramid structure above the field.\n\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera camz " << camz << std::endl; } else{ camz = atof(args[2].c_str()); returnstring << "camz set to " << camz << std::endl; } } else if (args[1].compare("camyaw") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera camyaw <double>\n"; returnstring << " Sets the new camera yaw. This is representative of the rotation of the map. (in degrees)\n\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera camyaw " << camyaw*180/3.14159265359 << std::endl; } else{ camyaw = 0; rotate_view(atof(args[2].c_str())*3.14159265359/180); returnstring << "camyaw set to " << camyaw*180/3.14159265359 << std::endl; } } else if (args[1].compare("zoomin_speed") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera zoomin_speed <double>\n"; returnstring << " Sets the multiplier for the speed of zooming in. Default is 0.05.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera zoomin_speed " << zoomin_speed << std::endl; } else{ zoomin_speed = atof(args[2].c_str()); returnstring << "zoomin_speed set to " << zoomin_speed << std::endl; } } else if (args[1].compare("zoomout_speed") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera zoomout_speed <double>\n"; returnstring << " Sets the multiplier for the speed of zooming out. Default is 0.075.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera zoomout_speed " << zoomout_speed << std::endl; } else{ zoomout_speed = atof(args[2].c_str()); returnstring << "zoomout_speed set to " << zoomout_speed << std::endl; } } else if (args[1].compare("zoom_friction") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera zoom_friction <double>\n"; returnstring << " Sets the multiplier for the friction in momentum zooming. Default is 0.3.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera zoom_friction " << zoom_friction << std::endl; } else{ zoom_friction = atof(args[2].c_str()); returnstring << "zoom_friction set to " << zoom_friction << std::endl; } } else if (args[1].compare("momentum_on") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera momentum_on <true/false\n"; returnstring << " Turns momentum effect of zooming on/off.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera momentum_on " << (momentum_on ? "true" : "false") << std::endl; } else{ if (args[2].compare("true") == 0){ momentum_on = true; returnstring << "momentum_on set to true\n"; } else if (args[2].compare("false") == 0){ momentum_on = false; returnstring << "momentum_on set to false\n"; } } } else if (args[1].compare("sidebuffer") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera x_sidebuffer <double>\n"; returnstring << " Sets the amount of in-game space the camera can see past the map. Default is 0.5.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera sidebuffer " << sidebuffer << std::endl; } else{ sidebuffer = atof(args[2].c_str()); returnstring << "sidebuffer set to " << sidebuffer << std::endl; } } else if (args[1].compare("pan_speed") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera pan_speed <double>\n"; returnstring << " Sets speed of panning by user input. Default is 0.25.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera pan_speed " << pan_speed << std::endl; } else{ pan_speed = atof(args[2].c_str()); returnstring << "pan_speed set to " << pan_speed << std::endl; } } else if (args[1].compare("fieldofview") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera fieldofvew <double>\n"; returnstring << " Sets the horizontal field of view of the camera (in degrees). Default is 75 degrees.\n"; } else if (args[2].compare("?") == 0){ returnstring << " camera fieldofview " << (int)(fieldofview_w*180/3.14156) << std::endl; } else{ fieldofview_w = atof(args[2].c_str()); returnstring << "fieldofview set to " << fieldofview_w << std::endl; fieldofview_w = fieldofview_w*3.14156/180.0; update_settings(); } } else if (args[1].compare("planeZs") == 0){ if (args[2].compare("help") == 0){ returnstring << " camera planeZs <Floor/Player> <double>\n"; returnstring << " Sets the z value for the entire plane of Foor/Player. This is used in calculations for zoom. Defaults are 0/0.2.\n"; } else{ if (args.size() < 4) return "Not enough arguments"; if (args[2].compare("Floor") == 0){ if(args[3].compare("?") == 0){ returnstring << "camera planeZs[Floor] " << planeZs[db::Floor] << std::endl; } else{ planeZs[db::Floor] = atof(args[3].c_str()); update_settings(); returnstring << "planeZs[Floor] set to " << planeZs[db::Floor] << std::endl; } } else if (args[2].compare("Player") == 0){ if(args[3].compare("?") == 0){ returnstring << "camera planeZs[Player] " << planeZs[db::Player] << std::endl; } else{ planeZs[db::Player] = atof(args[3].c_str()); update_settings(); returnstring << "planeZs[Player] set to " << planeZs[db::Player] << std::endl; } } } } else { returnstring << "camera command not parsed correctly. Try:\n"; returnstring << " camera help\n"; returnstring << " camera <command> help\n\n"; } return returnstring.str(); }
static void monitor_capture_update(void *data, obs_data_t *settings) { struct monitor_capture *mc = data; update_settings(mc, settings); }
bool DayWatcherThread::run() { SetThreadName("DayWatcher"); Log.Notice("DayWatcherThread", "Started."); _loaded = false; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); load_settings(); set_tm_pointers(); m_busy = false; _firstrun[0] = true; _firstrun[1] = true; m_heroic_reset = false; #ifdef WIN32 m_abortEvent = CreateEvent(NULL, NULL, FALSE, NULL); #else struct timeval now; struct timespec tv; pthread_mutex_init(&abortmutex,NULL); pthread_cond_init(&abortcond,NULL); #endif uint32 interv = 120000;//Daywatcher check interval (in ms), must be >> 30secs ! uint32 counter = 0; while(m_threadRunning) { m_busy=true; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); if(has_timeout_expired(&local_currenttime, &local_last_arena_time, arena_period)) update_arena(); if(has_timeout_expired(&local_currenttime, &local_last_daily_reset_time, DAILY)) { update_daily(); runEvents = true; } // reset will occur daily between 07:59:00 CET and 08:01:30 CET (players inside will get 60 sec countdown) // 8AM = 25200s uint32 umod = uint32(currenttime + 3600) % 86400; if(!m_heroic_reset && umod >= 25140 && umod <= 25140 + (interv/1000) + 30 ) { //It's approx 8AM, let's reset (if not done so already) Reset_Heroic_Instances(); m_heroic_reset = true; } if(m_heroic_reset && umod > 25140 + (interv/1000) + 30 ) m_heroic_reset = false; if(has_timeout_expired(&local_currenttime, &local_last_eventid_time, HOURLY)) { Log.Notice("DayWatcherThread", "Running Hourly In Game Events checks..."); for(EventsList::iterator itr = m_eventIdList.begin(); itr != m_eventIdList.end(); itr++) { if(!(*itr)->eventbyhour) continue; if((*itr)->isactive) { if((*itr)->lastactivated && !CheckHourlyEvent(&local_currenttime, (*itr)->starthour, (*itr)->endhour)) { (*itr)->isactive = false; SpawnEventId((*itr)->eventId, false); update_event_settings((*itr)->eventId,0); } else { if((*itr)->lastactivated && _firstrun[0]) { if(!SpawnEventId((*itr)->eventId)) break; } if(!(*itr)->lastactivated) { time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); runEvents = true; } continue; } } else { if(CheckHourlyEvent(&local_currenttime, (*itr)->starthour, (*itr)->endhour)) { if(!SpawnEventId((*itr)->eventId)) break; (*itr)->isactive = true; time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); continue; } } } _firstrun[0] = false; last_eventid_time = UNIXTIME; dupe_tm_pointer(localtime(&last_eventid_time), &local_last_eventid_time); m_dirty = true; } if(runEvents = true) // We run checks every 2 minutes. { if(_loaded) { runEvents = false; bool monthexpired = false; counter++; /* If we used sWorld.SpamWaitTime, we would do counter == (sWorld.SpamWaitTime/2 + 3) This would be say 30 minutes in config, so 30/2 = 15 + 2 = 17 and we set counter to 2 every time so 17 - 2 = 15 so 15x2 for every two minutes = 30 minutes timings.*/ if(counter <= 2) // First ticks { Log.Notice("DayWatcherThread", "Running In Game Events checks..."); } if(counter == 17/*15 + 2*/) // Tick every 30 minutes and reset. { Log.Notice("DayWatcherThread", "Running In Game Events checks..."); counter = 2; } for(EventsList::iterator itr = m_eventIdList.begin(); itr != m_eventIdList.end(); itr++) { if((*itr)->eventbyhour) continue; if((*itr)->isactive) { if((*itr)->lastactivated && has_eventid_expired((*itr)->activedays, (*itr)->lastactivated)) { (*itr)->isactive = false; SpawnEventId((*itr)->eventId, false); update_event_settings((*itr)->eventId,0); } else { if((*itr)->lastactivated && _firstrun[1]) { if(!SpawnEventId((*itr)->eventId)) break; } if(!(*itr)->lastactivated) { time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); runEvents = true; } continue; } } else { if((*itr)->monthnumber) { if(has_eventid_timeout_expired(&local_currenttime, ((*itr)->monthnumber - 1), MONTHLY)) { if(!(*itr)->daynumber) { if(!SpawnEventId((*itr)->eventId)) break; (*itr)->isactive = true; time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); continue; } monthexpired = true; } } if(monthexpired && (*itr)->daynumber && has_eventid_timeout_expired(&local_currenttime, (*itr)->daynumber, DAILY)) { monthexpired = false; time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); continue; } if((*itr)->daynumber && !(*itr)->monthnumber && has_eventid_timeout_expired(&local_currenttime, (*itr)->daynumber, DAILY)) { if(!SpawnEventId((*itr)->eventId)) break; (*itr)->isactive = true; time_t activated = (*itr)->lastactivated = UNIXTIME; update_event_settings((*itr)->eventId, activated); } } } _firstrun[1] = false; } } if(m_dirty) update_settings(); m_busy=false; if(!m_threadRunning) break; #ifdef WIN32 WaitForSingleObject(m_abortEvent, interv); #else gettimeofday(&now, NULL); tv.tv_sec = now.tv_sec + 120; tv.tv_nsec = now.tv_usec * 1000; pthread_mutex_lock(&abortmutex); pthread_cond_timedwait(&abortcond, &abortmutex, &tv); pthread_mutex_unlock(&abortmutex); #endif if(!m_threadRunning) break; } #ifdef WIN32 CloseHandle(m_abortEvent); #else pthread_mutex_destroy(&abortmutex); pthread_cond_destroy(&abortcond); #endif return true; }
void LIRenAttachmentEntity::update (float secs) { /* Check if background loading has finished. */ if (loaded) return; lisys_assert (entity == NULL); /* Wait for the mesh to load. */ if (!mesh->isLoaded ()) { if (loading_mesh) return; loading_mesh = true; #ifdef LIREN_BACKGROUND_LOADING Ogre::ResourceBackgroundQueue::getSingleton ().load ( "Mesh", mesh->getName (), mesh->getGroup ()); #else mesh->load (); #endif return; } /* Start loading dependencies. */ if (!loading_deps) { loading_deps = true; for (size_t i = 0 ; i < mesh->getNumSubMeshes () ; i++) { Ogre::SubMesh* sub = mesh->getSubMesh (i); if (sub->isMatInitialised ()) { Ogre::MaterialManager& mgr = Ogre::MaterialManager::getSingleton (); Ogre::MaterialPtr material = mgr.getByName (sub->getMaterialName (), mesh->getGroup ()); if (!material.isNull ()) { resources.push_back (material); #ifdef LIREN_BACKGROUND_LOADING Ogre::ResourceBackgroundQueue::getSingleton ().load ( "Material", material->getName (), material->getGroup ()); #else material->load (true); #endif } } } return; } // Wait for the dependencies to load. for (size_t i = 0 ; i < resources.size () ; i++) { Ogre::ResourcePtr& resource = resources[i]; if (!resource->isLoaded ()) return; } // Create the entity. Ogre::String e_name = render->id.next (); entity = render->scene_manager->createEntity (e_name, mesh->getName (), LIREN_RESOURCES_TEMPORARY); object->node->attachObject (entity); // Create the skeleton and its pose buffer. if (create_skeleton ()) { LIRenModelData* model = get_model (); lisys_assert (pose_buffer == NULL); if (model != NULL) { pose_buffer = limdl_pose_buffer_new_copy (model->rest_pose_buffer); lisys_assert (pose_buffer != NULL); lisys_assert (pose_buffer->bones.count == entity->getSkeleton ()->getNumBones ()); } } // Set the entity flags. entity->setCastShadows (object->get_shadow_casting ()); // Trigger queued texture replacements. // // This needs to be done before showing the entity in order to avoid // the textures flickering for a few frames. for (size_t i = 0 ; i < queued_texture_replaces.size () ; ++i) { LIRenTextureReplace& repl = queued_texture_replaces[i]; replace_texture_now (repl.name, repl.texture); } queued_texture_replaces.clear(); // Set entity visibility. // // If a visible entity is added to a hidden scene node, the entity is // still rendered. Hence, newly added entities needs to be explicitly // hidden or Ogre will render our invisible objects. */ entity->setVisible (object->get_visible ()); // Apply queued settings. update_settings (); // Clear the now useless dependency list. resources.clear (); loading_mesh = false; loading_deps = false; loaded = true; }
bool DayWatcherThread::run() { SetThreadName("DayWatcher"); Log.Notice("DayWatcherThread", "Started."); _loaded = false; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); load_settings(); set_tm_pointers(); m_busy = false; _firstrun[0] = true; _firstrun[1] = true; m_heroic_reset = false; #ifdef WIN32 m_abortEvent = CreateEvent(NULL, NULL, FALSE, NULL); #else struct timeval now; struct timespec tv; pthread_mutex_init(&abortmutex,NULL); pthread_cond_init(&abortcond,NULL); #endif uint32 interv = 120000; // Daywatcher check interval (in ms), must be >> 30secs ! while(m_threadRunning) { m_busy=true; currenttime = UNIXTIME; dupe_tm_pointer(localtime(¤ttime), &local_currenttime); if(has_timeout_expired(&local_currenttime, &local_last_arena_time, arena_period)) update_arena(); if(has_timeout_expired(&local_currenttime, &local_last_daily_reset_time, DAILY)) update_daily(); // reset will occur daily between 07:59:00 CET and 08:01:30 CET (players inside will get 60 sec countdown) // 8AM = 25200s uint32 umod = uint32(currenttime + 3600) % 86400; if(!m_heroic_reset && umod >= 25140 && umod <= 25140 + (interv/1000) + 30 ) { //It's approx 8AM, let's reset (if not done so already) Reset_Heroic_Instances(); m_heroic_reset = true; } if(m_heroic_reset && umod > 25140 + (interv/1000) + 30 ) m_heroic_reset = false; if(m_dirty) update_settings(); m_busy=false; if(!m_threadRunning) break; #ifdef WIN32 WaitForSingleObject(m_abortEvent, interv); #else gettimeofday(&now, NULL); tv.tv_sec = now.tv_sec + 120; tv.tv_nsec = now.tv_usec * 1000; pthread_mutex_lock(&abortmutex); pthread_cond_timedwait(&abortcond, &abortmutex, &tv); pthread_mutex_unlock(&abortmutex); #endif if(!m_threadRunning) break; } #ifdef WIN32 CloseHandle(m_abortEvent); #else pthread_mutex_destroy(&abortmutex); pthread_cond_destroy(&abortcond); #endif return true; }
int DisplayFltkMenu::act_on_command(int, Command *) { update_settings(); return 0; }
TextEditor::TextEditor() { code_editor = memnew(CodeTextEditor); add_child(code_editor); code_editor->add_constant_override("separation", 0); code_editor->connect("load_theme_settings", this, "_load_theme_settings"); code_editor->connect("validate_script", this, "_validate_script"); code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); update_settings(); code_editor->get_text_edit()->set_context_menu_enabled(false); code_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input"); context_menu = memnew(PopupMenu); add_child(context_menu); context_menu->connect("id_pressed", this, "_edit_option"); edit_hb = memnew(HBoxContainer); search_menu = memnew(MenuButton); edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); search_menu->get_popup()->connect("id_pressed", this, "_edit_option"); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE); search_menu->get_popup()->add_separator(); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE); goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->connect("id_pressed", this, "_edit_option"); edit_hb->add_child(edit_menu); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS); edit_menu->get_popup()->add_separator(); PopupMenu *convert_case = memnew(PopupMenu); convert_case->set_name("convert_case"); edit_menu->get_popup()->add_child(convert_case); edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case"); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE); convert_case->connect("id_pressed", this, "_edit_option"); highlighters["Standard"] = NULL; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu"); highlighter_menu->add_radio_check_item(TTR("Standard")); highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter"); code_editor->get_text_edit()->set_drag_forwarding(this); }
bool DayWatcherThread::run() { Log.Notice("DayWatcherThread", "Started."); load_settings(); m_busy = false; uint32 thread_sleep_time = HOURLY ; #if (defined( WIN32 ) || defined( WIN64 ) ) m_abortEvent = CreateEvent(NULL, NULL, FALSE, NULL); #else struct timeval now; struct timespec tv; pthread_mutex_init(&abortmutex,NULL); pthread_cond_init(&abortcond,NULL); #endif //special case since server will never run for 1 week while(ThreadState != THREADSTATE_TERMINATE) { m_busy=true; //thread_sleep_time = 5*60*1000; //5 minutes if( last_arena_time + arena_period < UNIXTIME ) update_arena(); if( last_daily_time + daily_period < UNIXTIME ) update_daily(); if( next_weekly_time < UNIXTIME ) update_weekly(); if(m_dirty) update_settings(); m_busy=false; if(ThreadState == THREADSTATE_TERMINATE) break; #if (defined( WIN32 ) || defined( WIN64 ) ) if (m_abortEvent) WaitForSingleObject(m_abortEvent, thread_sleep_time); #else gettimeofday(&now, NULL); tv.tv_sec = now.tv_sec + 120; tv.tv_nsec = now.tv_usec * 1000; pthread_mutex_lock(&abortmutex); pthread_cond_timedwait(&abortcond, &abortmutex, &tv); pthread_mutex_unlock(&abortmutex); #endif if(!m_running) break; } #if (defined( WIN32 ) || defined( WIN64 ) ) if (m_abortEvent) CloseHandle(m_abortEvent); #else pthread_mutex_destroy(&abortmutex); pthread_cond_destroy(&abortcond); #endif return true; }
void graphic_manager_context_force_update() { update_perspective(1); update_rendermode(1); update_settings(); }