netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer ./ChangeLog src/Editor/TemplateCreato...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer ./ChangeLog src/Editor/TemplateCreato...
Date: Wed, 26 Nov 2003 08:13:51 -0500

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/11/26 08:13:49

Modified files:
        .              : ChangeLog 
        src/Editor     : TemplateCreator.cpp TemplateSelectWidget.cpp 
                         TileSet.cpp TileSetView.cpp TileTemplate.cpp 
                         TileTemplate.hpp 
        src/Lib/Util   : FileSystem.hpp 
        src/NetPanzer/Classes/AI: Astar.cpp 
        src/NetPanzer/IRCLobby: IRCLobby.hpp 

Log message:
        -made scrolling in tilesetview working correctly
        -template loading and saving in the editor should work now

Patches:
Index: netpanzer/ChangeLog
diff -u netpanzer/ChangeLog:1.39 netpanzer/ChangeLog:1.40
--- netpanzer/ChangeLog:1.39    Mon Nov 24 08:34:21 2003
+++ netpanzer/ChangeLog Wed Nov 26 08:13:48 2003
@@ -1,3 +1,7 @@
+26-Nov-2003 by Matthias Braun
+-made scrolling in tilesetview working correctly
+-template loading and saving in the editor should work now
+
 24-Nov-2003 by Hankin Chick
 -created IRCLobbyServer, so IRCLobby should work by itself.
 -fixed repeatitive mouse move/dragged messages even when mouse didn't move
Index: netpanzer/src/Editor/TemplateCreator.cpp
diff -u netpanzer/src/Editor/TemplateCreator.cpp:1.3 
netpanzer/src/Editor/TemplateCreator.cpp:1.4
--- netpanzer/src/Editor/TemplateCreator.cpp:1.3        Sat Nov 22 11:00:38 2003
+++ netpanzer/src/Editor/TemplateCreator.cpp    Wed Nov 26 08:13:49 2003
@@ -4,9 +4,10 @@
 #include <exception>
 #include <SDL_image.h>
 
+#include "Util/Exception.hpp"
 #include "TemplateCreator.hpp"
 #include "TemplateSelectWidget.hpp"
-#include "Util/Exception.hpp"
+#include "TileTemplate.hpp"
 
 TemplateCreator::TemplateCreator(wxWindow* parent,
         TileSet* newtileset, const std::string& filename)
@@ -50,8 +51,7 @@
     try {
         TileTemplate* tiletemplate = selectwidget->createTemplate(tileset);
 
-        (void) tiletemplate;
-        // XXX TODO
+        tiletemplate->setName((const char*) templatenamectrl->GetValue());
 
         Close();
     } catch(std::exception& e) {
Index: netpanzer/src/Editor/TemplateSelectWidget.cpp
diff -u netpanzer/src/Editor/TemplateSelectWidget.cpp:1.3 
netpanzer/src/Editor/TemplateSelectWidget.cpp:1.4
--- netpanzer/src/Editor/TemplateSelectWidget.cpp:1.3   Sat Nov 22 17:50:44 2003
+++ netpanzer/src/Editor/TemplateSelectWidget.cpp       Wed Nov 26 08:13:49 2003
@@ -167,7 +167,7 @@
             tiletemplate->setTile(x, y, tile);
         }
     }
-
+            
     TileTemplate* result = tiletemplate.get();
     tileset->addTemplate(tiletemplate.release());
     return result;
Index: netpanzer/src/Editor/TileSet.cpp
diff -u netpanzer/src/Editor/TileSet.cpp:1.8 
netpanzer/src/Editor/TileSet.cpp:1.9
--- netpanzer/src/Editor/TileSet.cpp:1.8        Mon Nov 24 04:12:36 2003
+++ netpanzer/src/Editor/TileSet.cpp    Wed Nov 26 08:13:49 2003
@@ -143,10 +143,8 @@
     
     char** files = FileSystem::enumerateFiles(templatedir.c_str());
     for(char** file = files; *file != 0; file++) {
-        std::string filename = templatedir;
-        filename += *file;
-
-        // ...
+        TileTemplate* templ = new TileTemplate(this, *file);
+        templates.push_back(templ);
     }
 
     FileSystem::freeList(files);
@@ -163,7 +161,11 @@
     if(tilesize * header->tilecount != 0)
         file->write(tiledata, tilesize, header->tilecount);
 
-    // TODO save templates
+    std::vector<TileTemplate*>::iterator i;
+    for(i = templates.begin(); i != templates.end(); i++) {
+        TileTemplate* templ = *i;
+        templ->save();
+    }
 }
 
 const std::string& TileSet::getDirectory() const
Index: netpanzer/src/Editor/TileSetView.cpp
diff -u netpanzer/src/Editor/TileSetView.cpp:1.3 
netpanzer/src/Editor/TileSetView.cpp:1.4
--- netpanzer/src/Editor/TileSetView.cpp:1.3    Sat Nov 22 11:00:38 2003
+++ netpanzer/src/Editor/TileSetView.cpp        Wed Nov 26 08:13:49 2003
@@ -50,17 +50,22 @@
     tileywindow = getSurface()->h / tilesize.y;
     scrollpos = 0;
 
-    if(tileycount-tileywindow > 0)
-        SetScrollbar(0, 2, tileycount - tileywindow, getSurface()->h / 
tilesize.y);
+    if(tileycount - tileywindow > 0) {
+        SetScrollbar(wxVERTICAL, 0, 1, tileycount - tileywindow);
+    } else {
+        SetScrollbar(0, 0, 0, 0);
+    }
 
-    Refresh();
     paintContent();
+    Refresh();
 }
 
 void TileSetView::OnScroll(wxScrollEvent& event)
 {
-    scrollpos = event.GetPosition();
+    scrollpos = GetScrollPos(wxVERTICAL);
+    
     paintContent();
+    Refresh();
 }
 
 void TileSetView::redraw()
@@ -73,14 +78,12 @@
     if(tileset == 0)
         return;
 
-    std::cout << "Paint TIleset...\n";
-
     SDL_FillRect(getSurface(), 0,
             SDL_MapRGB(getSurface()->format, 255, 255, 255));
     
     size_t tilepos = scrollpos*tilexcount;
     int x=0, y=0;
-    while(tilepos < tileset->getTileCount() && y < tileywindow) {
+    while(tilepos < tileset->getTileCount() && y <= tileywindow) {
         SDL_Surface* surface = tileset->getTile(tilepos);
         SDL_Rect rect;
         rect.x = x*tilesize.x + tileborder.x;
@@ -106,9 +109,7 @@
         return false;
     }
         
-    std::cout << "Dropped filenames" << std::endl;
     for(size_t i=0; i<filenames.GetCount(); i++) {
-        std::cout << "Filename: " << filenames[i] << std::endl;
         try {
             TemplateCreator* templatecreator 
                 = new TemplateCreator(parentwindow, parentwindow->tileset,
@@ -123,6 +124,5 @@
 }
 
 BEGIN_EVENT_TABLE(TileSetView, SDLView)
-    EVT_SCROLL_ENDSCROLL(TileSetView::OnScroll)
-    EVT_SCROLL_THUMBRELEASE(TileSetView::OnScroll)
+    EVT_SCROLLWIN(TileSetView::OnScroll)
 END_EVENT_TABLE()
Index: netpanzer/src/Editor/TileTemplate.cpp
diff -u netpanzer/src/Editor/TileTemplate.cpp:1.4 
netpanzer/src/Editor/TileTemplate.cpp:1.5
--- netpanzer/src/Editor/TileTemplate.cpp:1.4   Mon Nov 24 04:12:36 2003
+++ netpanzer/src/Editor/TileTemplate.cpp       Wed Nov 26 08:13:49 2003
@@ -23,7 +23,7 @@
     name = newname;
     
     std::string filename = tileset->getDirectory();
-    filename += "/";
+    filename += "/templates/";
     filename += name;
     
     std::auto_ptr<ReadFile> file (FileSystem::openRead(filename));
@@ -45,7 +45,12 @@
 
 void TileTemplate::save()
 {
-    std::string filename = tileset->getDirectory();
+    std::string templatedir = tileset->getDirectory();
+    templatedir += "/templates";
+    if(!FileSystem::isDirectory(templatedir))
+        FileSystem::mkdir(templatedir);
+    
+    std::string filename = templatedir;
     filename += "/";
     filename += name;
     
Index: netpanzer/src/Editor/TileTemplate.hpp
diff -u netpanzer/src/Editor/TileTemplate.hpp:1.3 
netpanzer/src/Editor/TileTemplate.hpp:1.4
--- netpanzer/src/Editor/TileTemplate.hpp:1.3   Sat Nov 22 17:50:44 2003
+++ netpanzer/src/Editor/TileTemplate.hpp       Wed Nov 26 08:13:49 2003
@@ -24,6 +24,11 @@
 
     void save();
 
+    void setName(const std::string& newname)
+    { name = newname; }
+    const std::string& getName() const
+    { return name; }
+
     void setTile(size_t x, size_t y, size_t tilenum)
     { 
         assert(x < sizex);
Index: netpanzer/src/Lib/Util/FileSystem.hpp
diff -u netpanzer/src/Lib/Util/FileSystem.hpp:1.2 
netpanzer/src/Lib/Util/FileSystem.hpp:1.3
--- netpanzer/src/Lib/Util/FileSystem.hpp:1.2   Mon Nov 24 04:11:04 2003
+++ netpanzer/src/Lib/Util/FileSystem.hpp       Wed Nov 26 08:13:49 2003
@@ -157,12 +157,24 @@
     { return openWrite(filename.c_str()); }
 
     static void mkdir(const char* dirname);
+    static void mkdir(const std::string& dirname)
+    { mkdir(dirname.c_str()); }
     static void remove(const char* filename);
+    static void remove(const std::string& filename)
+    { remove(filename.c_str()); }
 
     static bool exists(const char* filename);
+    static bool exists(const std::string& filename)
+    { return exists(filename.c_str()); }
     static bool isDirectory(const char* filename);
+    static bool isDirectory(const std::string& filename)
+    { return isDirectory(filename.c_str()); }
     static bool isSymbolicLink(const char* filename);
+    static bool isSymbolicLink(const std::string& filename)
+    { return isSymbolicLink(filename.c_str()); }
     static int64_t getLastModTime(const char* filename);
+    static int64_t getLastModTime(const std::string& filename)
+    { return getLastModTime(filename.c_str()); }
 };
 
 #endif
Index: netpanzer/src/NetPanzer/Classes/AI/Astar.cpp
diff -u netpanzer/src/NetPanzer/Classes/AI/Astar.cpp:1.10 
netpanzer/src/NetPanzer/Classes/AI/Astar.cpp:1.11
--- netpanzer/src/NetPanzer/Classes/AI/Astar.cpp:1.10   Sat Nov 22 10:43:27 2003
+++ netpanzer/src/NetPanzer/Classes/AI/Astar.cpp        Wed Nov 26 08:13:49 2003
@@ -417,10 +417,10 @@
             PathingState::astar_gen_time = total_pathing_time;
             PathingState::astar_gen_time_total += total_pathing_time;
             *result_code = _path_result_goal_unreachable;
-            return( true );
+            return true;
         }
 
-    return( false );
+    return false;
 }
 
 void Astar::cleanUp( void )
Index: netpanzer/src/NetPanzer/IRCLobby/IRCLobby.hpp
diff -u netpanzer/src/NetPanzer/IRCLobby/IRCLobby.hpp:1.2 
netpanzer/src/NetPanzer/IRCLobby/IRCLobby.hpp:1.3
--- netpanzer/src/NetPanzer/IRCLobby/IRCLobby.hpp:1.2   Sun Nov 23 00:51:49 2003
+++ netpanzer/src/NetPanzer/IRCLobby/IRCLobby.hpp       Wed Nov 26 08:13:49 2003
@@ -32,7 +32,8 @@
 class IRCLobby;
 class IRCLobbyView;
 
-class NotifyIRCChangeName {
+class NotifyIRCChangeName
+{
 public:
     virtual void changeIRCName(std::string &newname) = 0;
     friend class IRCLobby;




reply via email to

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