netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer ./ChangeLog mk/jam/library.jam mk/jam...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer ./ChangeLog mk/jam/library.jam mk/jam...
Date: Wed, 26 Nov 2003 17:42:24 -0500

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/11/26 17:42:24

Modified files:
        .              : ChangeLog 
        mk/jam         : library.jam subdir.jam 
        src/Editor     : Editor.cpp Editor.hpp TileSet.cpp TileSet.hpp 
                         TileSetEditor.cpp TileSetList.cpp 
        src/Lib/Util   : FileSystem.cpp FileSystem.hpp 
Added files:
        src/Editor     : Map.cpp Map.hpp MapEditor.cpp MapEditor.hpp 
                         MapRenderer.cpp MapRenderer.hpp MapView.cpp 
                         MapView.hpp 

Log message:
        -started working on map rendering code for the editor and future 
netpanzer
        versions

Patches:
Index: netpanzer/ChangeLog
diff -u netpanzer/ChangeLog:1.40 netpanzer/ChangeLog:1.41
--- netpanzer/ChangeLog:1.40    Wed Nov 26 08:13:48 2003
+++ netpanzer/ChangeLog Wed Nov 26 17:42:24 2003
@@ -1,6 +1,8 @@
 26-Nov-2003 by Matthias Braun
 -made scrolling in tilesetview working correctly
 -template loading and saving in the editor should work now
+-started working on map rendering code for the editor and future netpanzer
+ versions
 
 24-Nov-2003 by Hankin Chick
 -created IRCLobbyServer, so IRCLobby should work by itself.
Index: netpanzer/mk/jam/library.jam
diff -u netpanzer/mk/jam/library.jam:1.2 netpanzer/mk/jam/library.jam:1.3
--- netpanzer/mk/jam/library.jam:1.2    Sat Nov 22 09:25:42 2003
+++ netpanzer/mk/jam/library.jam        Wed Nov 26 17:42:24 2003
@@ -39,7 +39,6 @@
   Always $(<)clean ;
   NotFile $(<)clean ;
   Clean $(<)clean : $(objects) ; # create target clean rule 
-  Depends clean : $(<)clean ;
 
   # so 'jam foo' works when it's really foo.exe (Windows) or foo.app (MacOS/X)
   if $(target) != $(<)
@@ -101,6 +100,7 @@
 
   Archive $(target) : $(objects) ;
   Clean $(<)clean : $(target) ;
+  Depends clean : $(<)clean ;
 
   if $(CMD.RANLIB) { Ranlib $(target) ; }
 
Index: netpanzer/mk/jam/subdir.jam
diff -u netpanzer/mk/jam/subdir.jam:1.1 netpanzer/mk/jam/subdir.jam:1.2
--- netpanzer/mk/jam/subdir.jam:1.1     Tue Sep 23 21:26:18 2003
+++ netpanzer/mk/jam/subdir.jam Wed Nov 26 17:42:24 2003
@@ -14,4 +14,21 @@
     LOCATE_SOURCE = [ FDirName $(LOCATE.OBJECTS) $(SUBDIR_TOKENS) ] ;
     LOCATE_TARGET = [ FDirName $(LOCATE.OBJECTS) $(SUBDIR_TOKENS) ] ;
 }
-       
+
+# fix bug in Jambase where SubInclude in the middle of a jam file made it break
+rule SubInclude
+{
+    if ! $($(<[1]))
+    {
+        Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
+    }
+
+    local save_SUBDIR_TOKENS = $(SUBDIR_TOKENS) ;
+
+    SubDir $(<) ;
+
+    include $(JAMFILE:D=$(SUBDIR)) ;
+
+    SubDir $(<[1]) $(save_SUBDIR_TOKENS) ;
+}
+    
Index: netpanzer/src/Editor/Editor.cpp
diff -u netpanzer/src/Editor/Editor.cpp:1.1 netpanzer/src/Editor/Editor.cpp:1.2
--- netpanzer/src/Editor/Editor.cpp:1.1 Sun Nov 16 17:40:59 2003
+++ netpanzer/src/Editor/Editor.cpp     Wed Nov 26 17:42:24 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 
 #include <wx/wx.h>
-#include <wx/dirctrl.h>
 
 #include "Editor.hpp"
 #include "TileSetEditor.hpp"
+#include "MapEditor.hpp"
 
 Editor::Editor()
     : wxFrame(0, -1, "Netpanzer Editor", wxPoint(50,50), wxSize(800,600))
@@ -32,12 +32,15 @@
     wxMenu* menufile = new wxMenu;
     menubar->Append(menufile, "&File");
     menufile->Append(ID_ABOUT, "&About");
+    menufile->Append(ID_TEST, "&Test");
     menufile->AppendSeparator();
     menufile->Append(ID_QUIT, "&Quit");
 
     SetMenuBar(menubar);
 
     // Connect slots
+    Connect(ID_TEST, wxEVT_COMMAND_MENU_SELECTED,
+            (wxObjectEventFunction) &Editor::OnTest);
     Connect(ID_QUIT, wxEVT_COMMAND_MENU_SELECTED,
             (wxObjectEventFunction) &Editor::OnQuit);
     Connect(ID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
@@ -52,6 +55,12 @@
 
 Editor::~Editor()
 {
+}
+
+void Editor::OnTest(wxCommandEvent& )
+{
+    MapEditor* editor = new MapEditor();
+    editor->Show();
 }
 
 void Editor::OnQuit(wxCommandEvent& )
Index: netpanzer/src/Editor/Editor.hpp
diff -u netpanzer/src/Editor/Editor.hpp:1.1 netpanzer/src/Editor/Editor.hpp:1.2
--- netpanzer/src/Editor/Editor.hpp:1.1 Sun Nov 16 17:40:59 2003
+++ netpanzer/src/Editor/Editor.hpp     Wed Nov 26 17:42:24 2003
@@ -26,12 +26,13 @@
     Editor();
     ~Editor();
 
+private:
     void OnQuit(wxCommandEvent& event);
     void OnAbout(wxCommandEvent& event);
+    void OnTest(wxCommandEvent& event);
 
-private:
     enum {
-        ID_QUIT=1, ID_ABOUT
+        ID_QUIT=1, ID_ABOUT, ID_TEST
     };
 };
 
Index: netpanzer/src/Editor/TileSet.cpp
diff -u netpanzer/src/Editor/TileSet.cpp:1.9 
netpanzer/src/Editor/TileSet.cpp:1.10
--- netpanzer/src/Editor/TileSet.cpp:1.9        Wed Nov 26 08:13:49 2003
+++ netpanzer/src/Editor/TileSet.cpp    Wed Nov 26 17:42:24 2003
@@ -96,8 +96,13 @@
     delete[] tiledata;
 }
 
-void TileSet::load(const std::string& dir)
+void TileSet::load(const std::string& name)
 {
+    this->name = name;
+    
+    std::string dir = "/tileset/";
+    dir += name;
+
     std::string filename = dir;
     filename += "/tiles.dat";
     
@@ -132,13 +137,13 @@
     }
 
     // read templates
-    readTemplates(dir);
+    readTemplates();
 }
 
-void TileSet::readTemplates(const std::string& newdir)
+void TileSet::readTemplates()
 {
-    dir = newdir;
-    std::string templatedir = dir;
+    std::string templatedir = "/tileset/";
+    templatedir += name;
     templatedir += "/templates/";
     
     char** files = FileSystem::enumerateFiles(templatedir.c_str());
@@ -152,7 +157,8 @@
 
 void TileSet::save()
 {
-    std::string filename = dir;
+    std::string filename = "/tileset/";
+    filename += name;
     filename += "/tiles.dat";
 
     std::auto_ptr<WriteFile> file (FileSystem::openWrite(filename));
@@ -168,14 +174,16 @@
     }
 }
 
-const std::string& TileSet::getDirectory() const
+std::string TileSet::getDirectory()
 {
-    return dir;
+    std::string result = "/tileset/";
+    result += name;
+    return result;
 }
 
-void TileSet::setDirectory(const std::string& newdirectory)
+void TileSet::setName(const std::string& newname)
 {
-    dir = newdirectory;
+    name = newname;
 }
 
 size_t TileSet::getTileCount() const
@@ -270,14 +278,13 @@
 
 void TileSet::resizeBuffer(size_t newbuffersize)
 {
-    std::auto_ptr<char> newbuffer (new char[newbuffersize]);
+    char* newbuffer = new char[newbuffersize];
 
     if(tiledata)
-        memcpy(newbuffer.get(),
-                tiledata, std::min(tilebuffersize, newbuffersize));
+        memcpy(newbuffer, tiledata, std::min(tilebuffersize, newbuffersize));
 
     delete[] tiledata;
-    tiledata = newbuffer.release();
+    tiledata = newbuffer;
     tilebuffersize = newbuffersize;
 }
 
Index: netpanzer/src/Editor/TileSet.hpp
diff -u netpanzer/src/Editor/TileSet.hpp:1.3 
netpanzer/src/Editor/TileSet.hpp:1.4
--- netpanzer/src/Editor/TileSet.hpp:1.3        Sat Nov 22 17:50:44 2003
+++ netpanzer/src/Editor/TileSet.hpp    Wed Nov 26 17:42:24 2003
@@ -19,14 +19,13 @@
     ~TileSet();
 
     /// loads a tileset from disk
-    void load(const std::string& dir);
+    void load(const std::string& name);
     /// save the tileset
     void save();
 
     /// returns the directory containing the tileset
-    const std::string& getDirectory() const;
-
-    void setDirectory(const std::string& newdirectory);
+    std::string getDirectory();
+    void setName(const std::string& newname);
 
     size_t getTileCount() const;
     SDL_Surface* getTile(size_t num);
@@ -41,14 +40,14 @@
 private:
     void resizeBuffer(size_t newbuffersize);
 
-    void readTemplates(const std::string& dir);
+    void readTemplates();
     
     TileSetHeader* header;
     size_t tilesize;
     char* tiledata;
     size_t tilebuffersize;
 
-    std::string dir;
+    std::string name;
     std::vector<TileTemplate*> templates;
 };
 
Index: netpanzer/src/Editor/TileSetEditor.cpp
diff -u netpanzer/src/Editor/TileSetEditor.cpp:1.4 
netpanzer/src/Editor/TileSetEditor.cpp:1.5
--- netpanzer/src/Editor/TileSetEditor.cpp:1.4  Sat Nov 22 17:50:44 2003
+++ netpanzer/src/Editor/TileSetEditor.cpp      Wed Nov 26 17:42:24 2003
@@ -63,7 +63,7 @@
         filename += newtileset;
 
         currenttileset = new TileSet();
-        currenttileset->load(filename);
+        currenttileset->load(newtileset);
 
         tilesetview->setTileSet(currenttileset);
     } catch(std::exception& e) {
Index: netpanzer/src/Editor/TileSetList.cpp
diff -u netpanzer/src/Editor/TileSetList.cpp:1.4 
netpanzer/src/Editor/TileSetList.cpp:1.5
--- netpanzer/src/Editor/TileSetList.cpp:1.4    Mon Nov 24 04:12:36 2003
+++ netpanzer/src/Editor/TileSetList.cpp        Wed Nov 26 17:42:24 2003
@@ -76,7 +76,7 @@
 
         std::auto_ptr<TileSet> tileset (new TileSet());
         std::string filename = newtileset;
-        tileset->setDirectory(filename);
+        tileset->setName("NewTileset");
         tileset->save();
 
         populateList();
Index: netpanzer/src/Lib/Util/FileSystem.cpp
diff -u netpanzer/src/Lib/Util/FileSystem.cpp:1.1 
netpanzer/src/Lib/Util/FileSystem.cpp:1.2
--- netpanzer/src/Lib/Util/FileSystem.cpp:1.1   Sat Nov 22 10:43:19 2003
+++ netpanzer/src/Lib/Util/FileSystem.cpp       Wed Nov 26 17:42:24 2003
@@ -256,6 +256,11 @@
     return PHYSFS_read(file, buffer, objsize, objcount);
 }
 
+bool ReadFile::isEOF()
+{
+    return PHYSFS_eof(file);
+}
+
 SDL_RWops* ReadFile::getSDLRWOps()
 {
     SDL_RWops* rwops = (SDL_RWops*) malloc(sizeof(SDL_RWops));
@@ -403,6 +408,16 @@
     return val;
 }
 
+void ReadFile::readLine(std::string& buffer)
+{
+    char c;
+    buffer = "";
+
+    while(!isEOF() && (c = read8()) != '\n') {
+        buffer += c;
+    }
+}
+
 //---------------------------------------------------------------------------
 
 WriteFile::WriteFile(PHYSFS_file* file)
@@ -492,3 +507,10 @@
         throw Exception("couldn't write: %s", PHYSFS_getLastError());
 }
 
+void WriteFile::writeLine(const std::string& buffer)
+{
+    if(write(buffer.c_str(), buffer.size(), 1) != 1)
+        throw Exception("Couldn't write line: %s", PHYSFS_getLastError());
+       
+    write8('\n');
+}
Index: netpanzer/src/Lib/Util/FileSystem.hpp
diff -u netpanzer/src/Lib/Util/FileSystem.hpp:1.3 
netpanzer/src/Lib/Util/FileSystem.hpp:1.4
--- netpanzer/src/Lib/Util/FileSystem.hpp:1.3   Wed Nov 26 08:13:49 2003
+++ netpanzer/src/Lib/Util/FileSystem.hpp       Wed Nov 26 17:42:24 2003
@@ -58,6 +58,8 @@
 class ReadFile : public File
 {
 public:
+       bool isEOF();   
+
     int64_t read(void* buffer, size_t objsize, size_t objcount);
 
     int8_t read8();
@@ -77,6 +79,8 @@
     int64_t readSBE64();
     uint64_t readUBE64();
 
+    void readLine(std::string& buffer);
+
     // Returns the SDL_RWops structure which can be used in several SDL
     // commands. Note that you have to free this structure with SDL_FreeRWops.
     // (Most SDL commands also have a freesrc parameter in their calls which 
you
@@ -117,6 +121,9 @@
     void writeSBE64(int64_t val);
     void writeUBE64(uint64_t val);
 
+    /// writes the text in the buffer and an additional newline
+    void writeLine(const std::string& line);
+
 protected:
     WriteFile(PHYSFS_file* file);
     friend class FileSystem;
@@ -178,4 +185,3 @@
 };
 
 #endif
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]