-void MapCoordinator()
-{
- Entity *theWorldspawn = NULL;
- const char *buffer;
- char line[20];
-
- // in any case we need a window to show the user what to do
- auto window = ui::Window(ui::window_type::TOP); // create the window
- gtk_window_set_transient_for(window, SunPlug::main_window); // make the window to stay in front of the main window
- window.connect("delete_event", G_CALLBACK(delete_event), NULL); // connect the delete event for the window
- window.connect("destroy", G_CALLBACK(destroy), NULL); // connect the destroy event for the window
- gtk_window_set_title(window, "ET-MapCoordinator"); // set the title of the window for the window
- gtk_window_set_resizable(window, FALSE); // don't let the user resize the window
- gtk_window_set_modal(window, TRUE); // force the user not to do something with the other windows
- gtk_container_set_border_width(GTK_CONTAINER(window), 10); // set the border of the window
-
- auto vbox = ui::VBox(FALSE, 10); // create a box to arrange new objects vertically
- window.add(vbox);
-
- scene::Path path = makeReference(GlobalSceneGraph().root()); // get the path to the root element of the graph
- scene::Instance *instance = GlobalSceneGraph().find(path); // find the instance to the given path
- AABB levelBoundingBox = instance->worldAABB(); // get the bounding box of the level
-
- theWorldspawn = Scene_FindEntityByClass("worldspawn"); // find the entity worldspawn
- if (theWorldspawn != 0) { // need to have a worldspawn otherwise setting a value crashes the radiant
- // next two if's: get the current values of the mapcoords
- buffer = theWorldspawn->getKeyValue("mapcoordsmins"); // upper left corner
- if (strlen(buffer) > 0) {
- strncpy(line, buffer, 19);
- map_minX = atoi(strtok(line, " ")); // minimum of x value
- map_minY = atoi(strtok(NULL, " ")); // maximum of y value
- } else {
- map_minX = 0;
- map_minY = 0;
- }
- buffer = theWorldspawn->getKeyValue("mapcoordsmaxs"); // lower right corner
- if (strlen(buffer) > 0) {
- strncpy(line, buffer, 19);
- map_maxX = atoi(strtok(line, " ")); // maximum of x value
- map_maxY = atoi(strtok(NULL, " ")); // minimum of y value
- } else {
- map_maxX = 0;
- map_maxY = 0;
- }
-
- globalOutputStream()
- << "SunPlug: calculating optimal coordinates\n"; // write to console that we are calculating the coordinates
- GetOptimalCoordinates(
- &levelBoundingBox); // calculate optimal mapcoords with the dimensions of the level bounding box
- globalOutputStream() << "SunPlug: adviced mapcoordsmins=" << minX << " " << maxY
- << "\n"; // console info about mapcoordsmins
- globalOutputStream() << "SunPlug: adviced mapcoordsmaxs=" << maxX << " " << minY
- << "\n"; // console info about mapcoordsmaxs
-
- auto spinner_adj_MinX = ui::Adjustment(map_minX, -65536.0, 65536.0, 1.0, 5.0,
- 0); // create adjustment for value and range of minimum x value
- auto spinner_adj_MinY = ui::Adjustment(map_minY, -65536.0, 65536.0, 1.0, 5.0,
- 0); // create adjustment for value and range of minimum y value
- auto spinner_adj_MaxX = ui::Adjustment(map_maxX, -65536.0, 65536.0, 1.0, 5.0,
- 0); // create adjustment for value and range of maximum x value
- auto spinner_adj_MaxY = ui::Adjustment(map_maxY, -65536.0, 65536.0, 1.0, 5.0,
- 0); // create adjustment for value and range of maximum y value
-
- auto button = ui::Button("Get optimal mapcoords"); // create button with text
- button.connect("clicked", G_CALLBACK(input_optimal), NULL); // connect button with callback function
- vbox.pack_start(button, FALSE, FALSE, 2); // insert button into vbox
-
- vbox.pack_start(ui::Widget::from(gtk_hseparator_new()), FALSE, FALSE, 2); // insert separator into vbox
-
- auto table = ui::Table(4, 3, TRUE); // create table
+void MapCoordinator(){
+ Entity *theWorldspawn = NULL;
+ const char *buffer;
+ char line[20];
+
+ // in any case we need a window to show the user what to do
+ auto window = ui::Window( ui::window_type::TOP ); // create the window
+ gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
+ window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
+ window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
+ gtk_window_set_title( window, "ET-MapCoordinator" ); // set the title of the window for the window
+ gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
+ gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
+
+ auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
+ window.add(vbox);
+
+ scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph
+ scene::Instance* instance = GlobalSceneGraph().find( path ); // find the instance to the given path
+ AABB levelBoundingBox = instance->worldAABB(); // get the bounding box of the level
+
+ theWorldspawn = Scene_FindEntityByClass( "worldspawn" ); // find the entity worldspawn
+ if ( theWorldspawn != 0 ) { // need to have a worldspawn otherwise setting a value crashes the radiant
+ // next two if's: get the current values of the mapcoords
+ buffer = theWorldspawn->getKeyValue( "mapcoordsmins" ); // upper left corner
+ if ( strlen( buffer ) > 0 ) {
+ strncpy( line, buffer, 19 );
+ map_minX = atoi( strtok( line, " " ) ); // minimum of x value
+ map_minY = atoi( strtok( NULL, " " ) ); // maximum of y value
+ }
+ else {
+ map_minX = 0;
+ map_minY = 0;
+ }
+ buffer = theWorldspawn->getKeyValue( "mapcoordsmaxs" ); // lower right corner
+ if ( strlen( buffer ) > 0 ) {
+ strncpy( line, buffer, 19 );
+ map_maxX = atoi( strtok( line, " " ) ); // maximum of x value
+ map_maxY = atoi( strtok( NULL, " " ) ); // minimum of y value
+ }
+ else {
+ map_maxX = 0;
+ map_maxY = 0;
+ }
+
+ globalOutputStream() << "SunPlug: calculating optimal coordinates\n"; // write to console that we are calculating the coordinates
+ GetOptimalCoordinates( &levelBoundingBox ); // calculate optimal mapcoords with the dimensions of the level bounding box
+ globalOutputStream() << "SunPlug: adviced mapcoordsmins=" << minX << " " << maxY << "\n"; // console info about mapcoordsmins
+ globalOutputStream() << "SunPlug: adviced mapcoordsmaxs=" << maxX << " " << minY << "\n"; // console info about mapcoordsmaxs
+
+ auto spinner_adj_MinX = ui::Adjustment( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value
+ auto spinner_adj_MinY = ui::Adjustment( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value
+ auto spinner_adj_MaxX = ui::Adjustment( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value
+ auto spinner_adj_MaxY = ui::Adjustment( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value
+
+ auto button = ui::Button( "Get optimal mapcoords" ); // create button with text
+ button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
+ vbox.pack_start( button, FALSE, FALSE, 2 ); // insert button into vbox
+
+ vbox.pack_start( ui::Widget::from(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox
+
+ auto table = ui::Table( 4, 3, TRUE ); // create table