void game :: init_gameobj(){ //auto loadlist = cfg->getlist("loadlist"); //#define MODULIFY(TYPE) lambdas["load_"#TYPE]=[&](){objs["load_"#TYPE]=new TYPE;} #ifdef GSHCKSNHDHFKS //MODULIFY(sym); //MODULIFY(grid); //MODULIFY(bzone); //MODULIFY(land); //MODULIFY(mesh); //MODULIFY(synapcity); //MODULIFY(demography); //MODULIFY(plot); //MODULIFY(cellnet); //MODULIFY(sandbox); //MODULIFY(game_mech_viewer); //MODULIFY(gax); //MODULIFY(orbit); //MODULIFY(quadtree); //MODULIFY(billiontest); //MODULIFY(land); //MODULIFY(netw); //MODULIFY(pathfinding); //MODULIFY(pathfinding2); //MODULIFY(pathfinding3); // MODULIFY(sandbox); // MODULIFY(spacepart); // MODULIFY(pathfinding4); // MODULIFY(path_movement); // MODULIFY(spacepart); MODULIFY(swarm); // MODULIFY(swarm2); #endif //MODULIFY(swarm2); auto load_this = "load_"+ cfg->getstring("load_this"); if(lambdas.find(load_this) != lambdas.end()) lambdas[load_this](); if(load_this!="load_zone" && load_this!="load_synapcity") { cout << "single-loaded " << load_this << endl; objs[load_this]->init(); show_keys(load_this); } //make_prog_objs(); }
bool game :: load_gameobj(string s){ //auto load_this = "load_"+ cfg->getstring("load_this"); for(auto&a:objs) delete a.second; objs.clear(); //show_keys(); auto load_this = "load_"+ s; if(lambdas.find(load_this) != lambdas.end()) { lambdas[load_this](); if(load_this!="load_zone" && load_this!="load_synapcity") { objs[load_this]->init(); show_keys(s); } } else { msg("no such module"); return false; } return false; }
// all configurations - > linker -> subsystem = windows //int WinMain() int main(int argc, char*argv[]) { //OutputDebugStringA("f*****g test in main2"); //cout << "f*****g test in main" << endl; //main(); configfile cfg; cfg.init("bedlab.cfg"); Vec2i windowsize; Vec2i screen_resolution = {int(VideoMode::getDesktopMode().width), int(VideoMode::getDesktopMode().height)} ; if (cfg.getvar<int>("auto_winsize")) { auto window_scale = cfg.getvar<Vec2>("window_scale"); windowsize = Vec2i(scal(Vec2(screen_resolution), window_scale)); } else { windowsize = cfg.getvar<Vec2i>("windowsize"); } winsize = Vec2(windowsize); UI.init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE wincenter = 0.5f*Vec2(windowsize); //msg(windowsize); Vec2i windowpos; //msg(screen_resolution); VideoMode::getDesktopMode().height; //SET(screen_resolution); if (cfg.getvar<int>("stick_left")) { windowpos = Vec2i(screen_resolution.x - windowsize.x - 10, 25); //msg(screen_resolution); //msg(windowpos); } else windowpos = (Vec2i(5, 25)); sf::RenderWindow window(sf::VideoMode(windowsize.x, windowsize.y), "bedlab!", 7, sf::ContextSettings(0, 0, 1)); window.setFramerateLimit(cfg.getvar<int>("fps_max")); frame_duration = 1.0f/cfg.getvar<int>("fps_max"); window.setPosition(windowpos); // add all the app { ADDAPP(smoothmouse); ADDAPP(mokio); ADDAPP(osm); ADDAPP(mousetest); ADDAPP(guns_axes); ADDAPP(nestedgrid); ADDAPP(recoil_test); ADDAPP(splosions); ADDAPP(industrio); ADDAPP(mason); ADDAPP(geomtest); ADDAPP(astar); ADDAPP(quadtree_test2); ADDAPP(springrecoil_test); ADDAPP(mine_solver); ADDAPP(sound_test); ADDAPP(clock_system_test); ADDAPP(populio); ADDAPP(simpleplot); ADDAPP(citynet); ADDAPP(bag); ADDAPP(delaun_distr); ADDAPP(spellmech); ADDAPP(short_tests); ADDAPP(geomtests); ADDAPP(tests_path); ADDAPP(test_perlin); ADDAPP(checkers_box); ADDAPP(swarming); ADDAPP(citynet2); ADDAPP(testbed); ADDAPP(geomtest_orient); ADDAPP(holosight); ADDAPP(recoil_simul); ADDAPP(recoil_spring); ADDAPP(bar_bump); ADDAPP(masonette); ADDAPP(mild_tests); ADDAPP(perlin_plain); /* ADDAPP(phone_pattern); ADDAPP(guns_test); ADDAPP(triangul); // just re add triangul.cpp to the project! ADDAPP(quadtree_test); ADDAPP(balldemo); apps["smoothmouse"] = smoothmouse(window,UI); ADDAPP(guns_test); ADDAPP(kdtree); */ } //{ // configfile descr_file; // descr_file.init("demo_descr.txt"); // set<string> avail; // for (auto&a : descr_file.dict) avail.insert(a.first); // for(auto&app :apps) // { // if (descr_file.dict.count(app.first)) // { // avail.erase(app.first); // } // } // for (auto&a : avail) // { // msgs("not loaded " + a); // } //} auto dont_load = cfg.getlist("dont_load"); for (auto&a : dont_load) { apps.erase(a); } //for (auto&a : dont_load) dont_load_these.insert(a); //auto dont_load_these = split2(dont_load," "); // read the string s = cfg.getstr("app"); if (cfg.getvar<int>("use_menu") == 1) { while (1) { string choice = appchooser(window, UI)(); //int i = 432; msgs("chosen " + choice); if (choice != "none") apps[choice](); else { break; } } } else { if (s == "") { msgs("######## error in config, app was not found! ########"); return -2; } if (!apps.count(s)) { msgs("######## app " + s + " not found! ######## "); throw runtime_error(string("app " + s + " not found!")); return -2; } vector<string> keys; auto choice = cfg.getstr("app"); show_keys(cfg.getstr("app"), keys); msgs(choice); for (auto&a : keys) msgs(a); apps[cfg.getstr("app")](); } return 0; }
/* Process command key. Returns non-zero if command results in picocom exit, zero otherwise. */ int do_command (unsigned char c) { static int dtr_up = 0; int newbaud, newflow, newparity, newbits, newstopbits; const char *xfr_cmd; char *fname; int r; switch (c) { case KEY_EXIT: return 1; case KEY_QUIT: term_set_hupcl(tty_fd, 0); term_flush(tty_fd); term_apply(tty_fd, 1); term_erase(tty_fd); return 1; case KEY_STATUS: show_status(dtr_up); break; case KEY_HELP: case KEY_KEYS: show_keys(); break; case KEY_PULSE: fd_printf(STO, "\r\n*** pulse DTR ***\r\n"); if ( term_pulse_dtr(tty_fd) < 0 ) fd_printf(STO, "*** FAILED\r\n"); break; case KEY_TOGGLE: if ( dtr_up ) r = term_lower_dtr(tty_fd); else r = term_raise_dtr(tty_fd); if ( r >= 0 ) dtr_up = ! dtr_up; fd_printf(STO, "\r\n*** DTR: %s ***\r\n", dtr_up ? "up" : "down"); break; case KEY_BAUD: case KEY_BAUD_UP: case KEY_BAUD_DN: if ( c== KEY_BAUD) { newbaud = read_baud(); if ( newbaud < 0 ) { fd_printf(STO, "*** cannot read baudrate ***\r\n"); break; } opts.baud = newbaud; } else if (c == KEY_BAUD_UP) { opts.baud = baud_up(opts.baud); } else { opts.baud = baud_down(opts.baud); } term_set_baudrate(tty_fd, opts.baud); tty_q.len = 0; term_flush(tty_fd); term_apply(tty_fd, 1); newbaud = term_get_baudrate(tty_fd, NULL); if ( opts.baud != newbaud ) { fd_printf(STO, "\r\n*** baud: %d (%d) ***\r\n", opts.baud, newbaud); } else { fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud); } set_tty_write_sz(newbaud); break; case KEY_FLOW: opts.flow = flow_next(opts.flow); term_set_flowcntrl(tty_fd, opts.flow); tty_q.len = 0; term_flush(tty_fd); term_apply(tty_fd, 1); newflow = term_get_flowcntrl(tty_fd); if ( opts.flow != newflow ) { fd_printf(STO, "\r\n*** flow: %s (%s) ***\r\n", flow_str[opts.flow], flow_str[newflow]); } else { fd_printf(STO, "\r\n*** flow: %s ***\r\n", flow_str[opts.flow]); } break; case KEY_PARITY: opts.parity = parity_next(opts.parity); term_set_parity(tty_fd, opts.parity); tty_q.len = 0; term_flush(tty_fd); term_apply(tty_fd, 1); newparity = term_get_parity(tty_fd); if (opts.parity != newparity ) { fd_printf(STO, "\r\n*** parity: %s (%s) ***\r\n", parity_str[opts.parity], parity_str[newparity]); } else { fd_printf(STO, "\r\n*** parity: %s ***\r\n", parity_str[opts.parity]); } break; case KEY_BITS: opts.databits = bits_next(opts.databits); term_set_databits(tty_fd, opts.databits); tty_q.len = 0; term_flush(tty_fd); term_apply(tty_fd, 1); newbits = term_get_databits(tty_fd); if (opts.databits != newbits ) { fd_printf(STO, "\r\n*** databits: %d (%d) ***\r\n", opts.databits, newbits); } else { fd_printf(STO, "\r\n*** databits: %d ***\r\n", opts.databits); } break; case KEY_STOP: opts.stopbits = stopbits_next(opts.stopbits); term_set_stopbits(tty_fd, opts.stopbits); tty_q.len = 0; term_flush(tty_fd); term_apply(tty_fd, 1); newstopbits = term_get_stopbits(tty_fd); if (opts.stopbits != newstopbits ) { fd_printf(STO, "\r\n*** stopbits: %d (%d) ***\r\n", opts.stopbits, newstopbits); } else { fd_printf(STO, "\r\n*** stopbits: %d ***\r\n", opts.stopbits); } break; case KEY_LECHO: opts.lecho = ! opts.lecho; fd_printf(STO, "\r\n*** local echo: %s ***\r\n", opts.lecho ? "yes" : "no"); break; case KEY_SEND: case KEY_RECEIVE: xfr_cmd = (c == KEY_SEND) ? opts.send_cmd : opts.receive_cmd; if ( xfr_cmd[0] == '\0' ) { fd_printf(STO, "\r\n*** command disabled ***\r\n"); break; } fname = read_filename(); if (fname == NULL) { fd_printf(STO, "*** cannot read filename ***\r\n"); break; } run_cmd(tty_fd, xfr_cmd, fname); free(fname); break; case KEY_BREAK: term_break(tty_fd); fd_printf(STO, "\r\n*** break sent ***\r\n"); break; default: break; } return 0; }