Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

DialogElevationTileTexture.cpp

Go to the documentation of this file.
00001 /*
00002  * DialogElevationTileTexture.cpp
00003  *
00004  * Part of Fly! Legacy project
00005  *
00006  * Copyright 2003 Chris Wallace
00007  *
00008  * Fly! Legacy is free software; you can redistribute it and/or modify
00009  *   it under the terms of the GNU General Public License as published by
00010  *   the Free Software Foundation; either version 2 of the License, or
00011  *   (at your option) any later version.
00012  *
00013  * Fly! Legacy is distributed in the hope that it will be useful,
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *   GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  *   along with Fly! Legacy; if not, write to the Free Software
00020  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  *
00023  * This dialog implements the Elevation Tile texture export feature of the Debug menu.
00024  *
00025  */
00026 
00027 
00028 #include "../Include/FlyLegacy.h"
00029 #include "../Include/Ui.h"
00030 #include "../Include/Utility.h"
00031 #include "../Include/Terrain.h"
00032 #include "../Include/Globals.h"
00033 
00034 typedef struct {
00035   puDialogBox*  dialog;
00036   puFrame*    frame;
00037   puText*     title;
00038 
00039   puInput*    et_input;
00040 
00041   puOneShot*    btnExport;
00042   puOneShot*    close;
00043 
00044   char      et_string[80];
00045 } SElevationTileDialogData;
00046 
00047 static SElevationTileDialogData *dt = NULL;
00048 
00049 
00050 static void elevation_tile_texture_export_cb (puObject* obj)
00051 {
00052   if (dt == NULL) return;
00053 
00054   int et;
00055   if (sscanf (dt->et_string, "%x", &et) == 1) {
00056 //    globals->terrainmgr->ExportElevationTileTexture (et);
00057   } else {
00058     DrawNoticeToUser ("ERROR : Elevation Tile must be hex value 000-3FF", 5);
00059   }
00060 }
00061 
00062 static void elevation_tile_texture_close_cb (puObject* obj)
00063 {
00064   if (dt == NULL) return;
00065 
00066   // Deleting the PUI dialog will delete all child widgets as well
00067   delete dt->dialog;
00068 
00069   // Delete dialog data structure
00070   delete dt;
00071   dt = NULL;
00072 }
00073 
00074 
00075 void elevation_tile_texture_dlg_create (void)
00076 {
00077   if (dt != NULL) return;
00078 
00079   // Instantiate data structure for dialog contents
00080   dt = new SElevationTileDialogData;
00081   strcpy (dt->et_string, "");
00082 
00083   // Define dialog size
00084   int frame_w = 300;
00085   int frame_h = 150;
00086 
00087   // Create dialog box
00088   dt->dialog = new puDialogBox (20, globals->screenHeight - 25 - frame_h);
00089   {
00090     // Frame
00091     dt->frame = new puFrame (0, 0, frame_w, frame_h);
00092 
00093     dt->title = new puText (10, 100);
00094     dt->title->setLabel ("Export Elevation Tile Texture:");
00095 
00096     // ET coordinate input field
00097     dt->et_input = new puInput (220, 60, 260, 80);
00098     dt->et_input->setLabel ("ET (000 - 3FF) :");
00099     dt->et_input->setLabelPlace (PUPLACE_CENTERED_LEFT);
00100     dt->et_input->setStyle (PUSTYLE_BOXED);
00101     dt->et_input->setValuator (dt->et_string);
00102 
00103     // Export button
00104     dt->btnExport = new puOneShot (110, 20, 170, 40);
00105     dt->btnExport->setLegend ("Export");
00106     dt->btnExport->makeReturnDefault (false);
00107     dt->btnExport->setStyle (PUSTYLE_SMALL_SHADED);
00108     dt->btnExport->setCallback (elevation_tile_texture_export_cb);
00109 
00110     // Close dialog button
00111     dt->close = new puOneShot (190, 20, 240, 40);
00112     dt->close->setLegend ("Close");
00113     dt->close->makeReturnDefault (false);
00114     dt->close->setStyle (PUSTYLE_SMALL_SHADED);
00115     dt->close->setCallback (elevation_tile_texture_close_cb);
00116   }
00117   dt->dialog->close ();
00118   dt->dialog->reveal ();
00119 }
00120 
SourceForge.net Logo Documentation generated by doxygen