void RoomList::set_room_data(const std::set <NetClient::RoomData>& rd) { this->clear(); button_rooms.clear(); last_button_is_create = false; // Make one button for each room for (Network::RoomCIt itr = rd.begin(); itr != rd.end(); ++itr) { // don't display the lobby as a room to switch into if (itr->number == 0) continue; if (((int) buttons.size() + 1) * button_yl > get_yl()) break; button_rooms.push_back(itr->number); buttons.push_back( TextButton(0, buttons.size() * button_yl, get_xl(), button_yl)); std::ostringstream str; str << Language::win_lobby_room_number << (int) itr->number << ", " << (int) itr->members << " " << (itr->members == 1 ? Language::win_lobby_room_player : Language::win_lobby_room_players); buttons.back().set_text(str.str()); buttons.back().set_undraw_color(color[COL_API_M]); } // Room creation button if (((int) buttons.size() + 1) * button_yl <= (int) get_yl()) { button_rooms.push_back(0); buttons.push_back( TextButton(0, buttons.size() * button_yl, get_xl(), button_yl)); buttons.back().set_text(Language::win_lobby_room_create); buttons.back().set_undraw_color(color[COL_API_M]); last_button_is_create = true; } for (std::vector <TextButton> ::iterator itr = buttons.begin(); itr != buttons.end(); ++itr) add_child(*itr); set_draw_required(); }
void Map::draw(Torbit& target) { const bool z = zoom; int less_x = 0; int less_y = 0; // how much is the screen larger than the map? if (!get_torus_x() && get_xl() * (z+1) < screen_xl) less_x = screen_xl - get_xl() * (z+1); if (!get_torus_y() && get_yl() * (z+1) < screen_yl) less_y = screen_yl - get_yl() * (z+1); for (int x = less_x/2; x < screen_xl-less_x/2; x += get_xl()*(z+1)) { for (int y = less_y; y < screen_yl; y += get_yl()*(z+1)) { draw_at(target, x, y); if (less_y != 0) break; } if (less_x != 0) break; } // Draw the screen border const int c = useR->screen_border_colored ? color[COL_SCREEN_BORDER] : 0; if (less_x) { rectfill(target.get_al_bitmap(), 0, 0, less_x/2 - 1, screen_yl - 1, c); rectfill(target.get_al_bitmap(), screen_xl - less_x/2, 0, screen_xl - 1, screen_yl - 1, c); } if (less_y) rectfill(target.get_al_bitmap(), less_x/2, 0, screen_xl - less_x/2 - 1, less_y - 1, c); }
GraphicBG& GraphicBG::operator = (const GraphicBG& o) { Graphic::operator = (o); // Umweg ueber temporaeren Zeiger macht Selbstzuweisung absturzfrei BITMAP* temp = create_bitmap(get_xl(), get_yl()); blit(o.bg, temp, 0, 0, 0, 0, get_xl(), get_yl()); destroy_bitmap(bg); bg = temp; return *this; }
GraphicBG::GraphicBG(const GraphicBG& o) : Graphic(o), drawn (o.drawn), x_drawn(o.x_drawn), y_drawn(o.y_drawn) { bg = create_bitmap(get_xl(), get_yl()); blit(o.bg, bg, 0, 0, 0, 0, get_xl(), get_yl()); }
void Frame::draw_self() { // Diese hier machen das Zeichnen übersichtlicher. BITMAP* g = get_ground().get_al_bitmap(); const int x1 = get_x_here() - 2; const int y1 = get_y_here() - 2; const int x2 = get_x_here() + 1 + get_xl(); const int y2 = get_y_here() + 1 + get_yl(); // Farben wählen int col_1 = color[COL_API_D]; int col_3 = color[COL_API_L]; // Acquiren, malen, freilassen acquire_bitmap(g); vline (g, x1, y1, y2-1, col_1); // Links außen vline (g, x1+1, y1, y2-2, col_1); // Links innen hline (g, x1+2, y1, x2-1, col_1); // Oben außen hline (g, x1+2, y1+1, x2-2, col_1); // Oben innen vline (g, x2, y1+1, y2, col_3); // Rechts außen vline (g, x2-1, y1+2, y2, col_3); // Rechts innen hline (g, x1+1, y2, x2-2, col_3); // Unten außen hline (g, x1+2, y2-1, x2-2, col_3); // Unten innen release_bitmap(g); }
void DirList::add_button(const int i, const std::string& str) { TextButton* t = new TextButton(0, i*20, get_xl(), 20); t->set_undraw_color(color[COL_API_M]); t->set_text(str); buttons.push_back(t); add_child(*t); }
void Map::load_masked_screen_rectangle(Torbit& src) { if (get_xl() != src.get_xl() || get_yl() != src.get_yl()) return; const int& x = screen_x; const int& y = screen_y; const int& xl = get_xl(); const int& yl = get_yl(); const bool& tx = get_torus_x(); const bool& ty = get_torus_y(); const int min_w = screen_xl; const int min_h = screen_yl; BITMAP* s = src.get_al_bitmap(); BITMAP* b = get_al_bitmap(); masked_blit(s, b, x, y, x, y, min_w, min_h); if (tx) masked_blit(s, b, x-xl, y, x-xl, y, min_w, min_h); if (ty) masked_blit(s, b, x, y-yl, x, y-yl, min_w, min_h); if (tx&&ty) masked_blit(s, b, x-xl, y-yl, x-xl, y-yl, min_w, min_h); }
GraphicBG::GraphicBG(const Cutbit& c, Torbit& gr, int new_x, int new_y) : Graphic(c, gr, new_x, new_y), drawn (false), x_drawn(0), y_drawn(0) { bg = create_bitmap(get_xl(), get_yl()); }
void Frame::undraw_self() { if (!get_undraw_color()) return; const int x1 = get_x_here() - 2; const int y1 = get_y_here() - 2; const int x2 = get_x_here() + 1 + get_xl(); const int y2 = get_y_here() + 1 + get_yl(); rectfill(get_ground().get_al_bitmap(), x1, y1, x2, y2, get_undraw_color()); }
void Map::clear_screen_rectangle(int col) { const int& x1 = screen_x; const int& y1 = screen_y; const int& x2 = get_xl(); const int& y2 = get_yl(); const bool& tx = get_torus_x(); const bool& ty = get_torus_y(); BITMAP* b = get_al_bitmap(); rectfill(b, x1, y1, x2, y2, col); if (tx) rectfill(b, 0, y1, x1, y2, col); if (ty) rectfill(b, x1, 0, x2, y1, col); if (tx&&ty) rectfill(b, 0, 0, x1, y1, col); }
int main(int argc,char *argv[]) { printf("SRCSWAP - Source code mark/replace utility Version 1.0000 %s",__DATE__); markchar='~'; ovrwrit = 0; disp=0; nomark=0; noquote=0; xargc=argc; for (i=0;i<argc;i++) { xargv[i] = argv[i]; } if (argc < 4) format(); i = 4; while (i < argc) { getopt(i); i++; } getinp(); getout(); top=NULL; cur=NULL; get_xl(); srt_xl(); done=0; printf("\nProcessing..."); while (!(done)) { getline(); process(); } fclose(outf); return(0); }
void Button::draw_self() { // Diese hier machen das Zeichnen übersichtlicher. BITMAP* g = get_ground().get_al_bitmap(); const int x1 = get_x_here(); const int y1 = get_y_here(); const int x2 = get_x_here() + get_xl() - 1; const int y2 = get_y_here() + get_yl() - 1; if (down) { color_1 = color[COL_API_DOWN_D]; color_2 = color[COL_API_DOWN_M]; color_3 = color[COL_API_DOWN_L]; color_text = color[COL_TEXT ]; } else if (on) { color_1 = color[COL_API_ON_D]; color_2 = color[COL_API_ON_M]; color_3 = color[COL_API_ON_L]; color_text = color[COL_TEXT_ON ]; } else { color_1 = color[COL_API_L ]; color_2 = color[COL_API_M ]; color_3 = color[COL_API_D ]; color_text = color[COL_TEXT]; } // Jetzt wird's ernst acquire_bitmap(g); // Jetzt malen! putpixel(g, x1, y2, color_2); // Unten links außen putpixel(g, x1+1, y2-1, color_2); // Unten links innen putpixel(g, x2-1, y1+1, color_2); // Oben rechts außen putpixel(g, x2, y1, color_2); // Oben rechts innen rectfill(g, x1+2, y1+2, x2-2, y2-2, color_2); // Mittelfläche vline (g, x1, y1, y2-1, color_1); // Links außen vline (g, x1+1, y1, y2-2, color_1); // Links innen hline (g, x1+2, y1, x2-1, color_1); // Oben außen hline (g, x1+2, y1+1, x2-2, color_1); // Oben innen vline (g, x2, y1+1, y2, color_3); // Rechts außen vline (g, x2-1, y1+2, y2, color_3); // Rechts innen hline (g, x1+1, y2, x2-2, color_3); // Unten außen hline (g, x1+2, y2-1, x2-2, color_3); // Unten innen release_bitmap(g); }
void Map::draw_at( Torbit& target, const int offx, // start this much away from the screen's upper left edge const int offy ) { const int& mapxl = get_xl(); const int& mapyl = get_yl(); const int scrx = !zoom ? screen_x: Help::mod(screen_x+screen_xl/4, mapxl); const int scry = !zoom ? screen_y: Help::mod(screen_y+screen_yl/4, mapyl); const int lx = std::min(!zoom ? screen_xl : screen_xl / 2, mapxl); const int ly = std::min(!zoom ? screen_yl : screen_yl / 2, mapyl); const bool short_x = scrx + lx > mapxl; const bool short_y = scry + ly > mapyl; const int shoby_x = short_x ? scrx + lx - mapxl : 0; const int shoby_y = short_y ? scry + ly - mapyl : 0; if (! zoom) { masked_blit(get_al_bitmap(), target.get_al_bitmap(), scrx, scry, // source x/y start offx, offy, // target x/y start short_x ? mapxl - scrx : lx, // x-length and y-length of area to copy short_y ? mapyl - scry : ly); if (short_x && get_torus_x()) { masked_blit(get_al_bitmap(), target.get_al_bitmap(), 0, scry, offx + mapxl - scrx, offy, scrx + lx - mapxl, short_y ? mapyl - scry : ly); } if (short_y && get_torus_y()) { masked_blit(get_al_bitmap(), target.get_al_bitmap(), scrx, 0, offx, offy + mapyl - scry, short_x ? mapxl - scrx : lx, scry + ly - mapyl); } if (short_x && short_y && get_torus_x() && get_torus_y()) { masked_blit(get_al_bitmap(), target.get_al_bitmap(), 0, 0, offx + mapxl - scrx, offy + mapyl - scry, scrx + lx - mapxl, scry + ly - mapyl); } } else { // This is the above code copied, but with zoom things hacked in blit_double(get_al_bitmap(), target.get_al_bitmap(), scrx, scry, // source x/y start short_x ? mapxl - scrx : lx, // x-length and y-length of the source short_y ? mapyl - scry : ly, offx, // target x/y start offy); if (short_x && get_torus_x()) { blit_double(get_al_bitmap(), target.get_al_bitmap(), 0, scry, shoby_x, short_y ? mapyl - scry : ly, offx + 2 * (mapxl - scrx), offy); } if (short_y && get_torus_y()) { blit_double(get_al_bitmap(), target.get_al_bitmap(), scrx, 0, short_x ? mapxl - scrx : lx, shoby_y, offx, offy + 2 * (mapyl - scry)); } if (short_x && short_y && get_torus_x() && get_torus_y()) { blit_double(get_al_bitmap(), target.get_al_bitmap(), 0, 0, shoby_x, shoby_y, offx + 2 * (mapxl - scrx), offy + 2 * (mapyl - scry)); } } // end if/else zoom }
Lobby::Lobby() : Window(0, 0, LEMSCR_X, LEMSCR_Y, Language::win_lobby_title), exit_with (EXIT_WITH_NOTHING), mode (NOT_CONNECTED), browser (0), preview (LEMSCR_X - 20 - preview_xl, 40, preview_xl, 160), // 160 ist loblist_y_len room_list (LEMSCR_X - 20 - preview_xl, 40, preview_xl, 160), button_level(LEMSCR_X - 20 - button_xl, medium_row_y, button_xl), button_ready(20, medium_row_y, button_xl), button_exit (LEMSCR_X - 20 - button_xl, chat_type_y, button_xl), unstable_central(get_xl() / 2, start_but_y, Language::win_lobby_unstable_central, Api::Label::CENTERED), start_central(start_but_x, start_but_y, start_but_xl), start_server(start_but_x, start_but_y + 1*start_but_ys, start_but_xl), start_client(start_but_x, start_but_y + 2*start_but_ys, start_but_xl/2), start_ip (LEMSCR_X/2, start_but_y + 2*start_but_ys, start_but_xl/2), chat (20, console_y, console_xl), chat_type (chat_type_x, chat_type_y, LEMSCR_X - 40 - chat_type_x - button_xl), desc_chat (20, chat_type_y, Language::win_lobby_chat), players (20, 40), button_spec (GraLib::get(gloB->file_bitmap_lobby_spec), 180, 200 - 32) { // Don't show the GARDEN style by placing it off the screen for (unsigned i = LixEn::GARDEN; i < LixEn::STYLE_MAX; ++i) { button_color.push_back(LobbyColorButton( (i < LixEn::RED ? 10000 : 180 + (i-2) % 2 * LobbyColorButton::this_xl), 40 + (i-2) / 2 * LobbyColorButton::this_yl, static_cast <LixEn::Style> (i))); } // Adding children add_child(preview); add_child(room_list); add_child(button_level); add_child(button_ready); add_child(button_exit); add_child(unstable_central); add_child(start_central); add_child(start_server); add_child(start_client); add_child(start_ip); add_child(chat); add_child(chat_type); add_child(desc_chat); add_child(players); add_child(button_spec); for (std::vector <LobbyColorButton> ::iterator itr = button_color.begin(); itr != button_color.end(); ++itr) { add_child(*itr); } for (std::set <Element*> ::iterator itr = get_children().begin(); itr != get_children().end(); ++itr) { (**itr).set_undraw_color(color[COL_API_M]); } // Hotkeys and texts button_level .set_text(Language::win_lobby_select_level); button_ready .set_text(Language::win_lobby_ready); start_central.set_text(Language::win_lobby_start_central); start_server .set_text(Language::win_lobby_start_server); start_client .set_text(Language::win_lobby_start_client); button_ready .set_hotkey(useR->key_me_okay); button_exit .set_hotkey(useR->key_me_exit); chat_type .set_hotkey(useR->key_chat); chat_type .set_on_enter(this, chat_on_enter_callback); start_ip .set_scroll(); start_ip .set_text(gloB->ip_last_used); start_ip .set_on_enter(this, start_ip_on_enter_callback); chat_type .set_scroll(); // Coming back into the menu after a game if (Network::get_started()) { set_mode(INSIDE_ROOM); players.set_data(Network::get_player_data()); if (Network::get_room() == 0) room_list.set_room_data(Network::get_room_data()); else preview.set_level(Network::get_level()); button_ready.set_on(Network::get_ready()); for (unsigned i = 0; i < button_color.size(); ++i) { if (i == (unsigned)Network::get_style() && ! Network::get_spec()) { button_color[i].set_on(); useR->network_last_style = i; } else button_color[i].set_off(); } if (Network::get_spec()) button_spec.set_on(); } // Or just about to start a network session else { set_mode(NOT_CONNECTED); Console::clear(); if (gloB->version_stable) { Console::push_back(Language::net_chat_welcome_1); Console::push_back(Language::net_chat_welcome_2); } else { Console::push_back(Language::net_chat_unstable_1); Console::push_back(Language::net_chat_unstable_2); } } }