diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-04-18 01:01:56 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-04-18 01:01:56 +0000 |
commit | 4d95c5cdaa720c5207a5f5b0d97a884a7ed1a3ab (patch) | |
tree | d44f4b49f78108b10a651c6a8c4d504093c7cafe | |
parent | 14123d8051df5cbae0331c28f63a8ec3ef9a3852 (diff) |
Added core of group explode. Also fixed modal windows as well as can be done with MS.
-rw-r--r-- | groupexplode/.cvsignore | 2 | ||||
-rw-r--r-- | groupexplode/GNUmakefile | 69 | ||||
-rw-r--r-- | groupexplode/config.cpp | 62 | ||||
-rw-r--r-- | groupexplode/config.h | 47 | ||||
-rw-r--r-- | groupexplode/dialog.cpp | 97 | ||||
-rw-r--r-- | groupexplode/dialog.h | 54 | ||||
-rw-r--r-- | groupexplode/main.cpp | 82 | ||||
-rw-r--r-- | groupexplode/resource.h | 30 | ||||
-rw-r--r-- | groupexplode/resource.rc | 17 | ||||
-rw-r--r-- | opengl/GNUmakefile | 10 | ||||
-rw-r--r-- | opengl/dialog.rc | 2 | ||||
-rw-r--r-- | opengl/generate.cpp | 22 | ||||
-rw-r--r-- | opengl/generate.h | 7 | ||||
-rw-r--r-- | opengl/main.cpp | 10 |
14 files changed, 487 insertions, 24 deletions
diff --git a/groupexplode/.cvsignore b/groupexplode/.cvsignore new file mode 100644 index 0000000..3bb13c3 --- /dev/null +++ b/groupexplode/.cvsignore @@ -0,0 +1,2 @@ +depend.mak
+msGrpExplode.dll
\ No newline at end of file diff --git a/groupexplode/GNUmakefile b/groupexplode/GNUmakefile new file mode 100644 index 0000000..12db8dc --- /dev/null +++ b/groupexplode/GNUmakefile @@ -0,0 +1,69 @@ +# MSPlugins - Simple OpenGL Milkshape plugin +# +# Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ------------------------------------------------------------------------- +# +# $Id: GNUmakefile,v 1.1 2005-04-18 01:01:56 ianc Exp $ +# +include ../make.conf + +TARGET = msGrpExplode + +RES = resource + +SOURCES = main.cpp \ + dialog.cpp \ + config.cpp + +HEADERS = $(RES).h \ + dialog.h \ + config.h + +OBJECTS = $(SOURCES:.cpp=.o) $(RES).o + +OUTDLL = $(TARGET).dll + +WRAPPER = ../wrapper + +DLLLIBS = $(WRAPPER)/mingwms.lib $(MILKSHAPE)/lib/msModelLib.lib \ + `w32dlib-config --libs` + +FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) -Wall `w32dlib-config --cflags` \ + -DREGISTRY_USAGE=$(REGISTRY_USAGE) + + +$(OUTDLL): $(OBJECTS) + dllwrap --dllname=$(OUTDLL) --driver-name=c++ $(OBJECTS) $(DLLLIBS) + +$(RES).o: $(RES).rc + windres -i $(RES).rc -o $(RES).o + +%.o: %.cpp + $(CXX) -c $(FLAGS) $< -o $@ + +-include depend.mak + +clean: + -rm -f $(OUTDLL) $(OUTLIB) $(OBJECTS) + +depend: + @echo Dependencies updated.... + $(CXX) -MM $(FLAGS) $(SOURCES) > depend.mak + + +# END OF FILE diff --git a/groupexplode/config.cpp b/groupexplode/config.cpp new file mode 100644 index 0000000..59f87f0 --- /dev/null +++ b/groupexplode/config.cpp @@ -0,0 +1,62 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#include "config.h" +#include <w32dlib/w32dlib.h> + +#define KEY "Software\\Noddybox\\MSPluginState\\GroupExplode" + +bool Config::m_init=false; +bool Config::m_rmOrig=false; + +void Config::Load() +{ + if (!m_init) + { + m_init=true; + + m_rmOrig=false; + +#if REGISTRY_USAGE!=0 + + W32DLib::Registry r(HKEY_CURRENT_USER,KEY); + + r.Read("RemoveOriginal",m_rmOrig); + +#endif + + } +} + +void Config::Save() +{ +#if REGISTRY_USAGE!=0 + + W32DLib::Registry r(HKEY_CURRENT_USER,KEY,REGISTRY_USAGE==2); + + r.Write("RemoveOriginal",m_rmOrig); + +#endif +} + +bool Config::RemoveOriginal() {return m_rmOrig;} +void Config::RemoveOriginal(bool flag) {m_rmOrig=flag;} diff --git a/groupexplode/config.h b/groupexplode/config.h new file mode 100644 index 0000000..8d00356 --- /dev/null +++ b/groupexplode/config.h @@ -0,0 +1,47 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#ifndef CONFIG_H +#define CONFIG_H + +#include <string> + +class Config +{ +public: + + static void Load(); + + static void Save(); + + static bool RemoveOriginal(); + static void RemoveOriginal(bool flag); + +private: + Config(); + + static bool m_init; + + static bool m_rmOrig; +}; + +#endif // CONFIG_H diff --git a/groupexplode/dialog.cpp b/groupexplode/dialog.cpp new file mode 100644 index 0000000..6816de9 --- /dev/null +++ b/groupexplode/dialog.cpp @@ -0,0 +1,97 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +static const char rcs_id[]="$Id$"; + +#include "dialog.h" +#include "resource.h" +#include "config.h" + + +///////////////////////////////////////////////////////////////////////////// +// Dialog + + +Dialog::Dialog(const StringList& groups) + : m_ok(this,IDC_OKBUT,0) + , m_cancel(this,IDC_CANCELBUT,0) + , m_rmOrig(this,IDC_RMORIG,0) + , m_groups(this,IDC_GROUP,0) + , m_sel(-1) + , m_groupList(groups) +{ + Config::Load(); + + m_ok.OnPress + (this,static_cast<W32DLib::W32DLibCallback>(&Dialog::OnOK)); + + m_cancel.OnPress + (this,static_cast<W32DLib::W32DLibCallback>(&Dialog::OnCancel)); +} + + +///////////////////////////////////////////////////////////////////////////// +// Dialog public members + +int Dialog::ResourceID() +{ + return GR_DIALOG; +} + + +void Dialog::OnInit() +{ + StringList::const_iterator i; + + for(i=m_groupList.begin();i!=m_groupList.end();++i) + { + m_groups.AddString(*i); + } + + m_groups.SelectedIndex(0); + + m_rmOrig.SetState(Config::RemoveOriginal()); +} + + +int Dialog::GetSelectedGroup() +{ + return m_sel; +} + + +///////////////////////////////////////////////////////////////////////////// +// Dialog message handlers + +BOOL Dialog::OnOK(UINT msg, WPARAM wp, LPARAM lp) +{ + Config::RemoveOriginal(m_rmOrig.GetState()); + m_sel=m_groups.SelectedIndex(); + + Close(IDOK); + return TRUE; +} + + +BOOL Dialog::OnCancel(UINT msg, WPARAM wp, LPARAM lp) +{ + Close(IDCANCEL); + return TRUE; +} diff --git a/groupexplode/dialog.h b/groupexplode/dialog.h new file mode 100644 index 0000000..f68efa5 --- /dev/null +++ b/groupexplode/dialog.h @@ -0,0 +1,54 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#ifndef DIALOG_H +#define DIALOG_H + +#include <w32dlib/w32dlib.h> + +typedef std::vector<std::string> StringList; + +class Dialog : public W32DLib::Dialog +{ +public: + Dialog(const StringList& groups); + + int ResourceID(); + + void OnInit(); + + int GetSelectedGroup(); + +private: + + W32DLib::Button m_ok; + W32DLib::Button m_cancel; + W32DLib::AutoCheck m_rmOrig; + W32DLib::ComboBox m_groups; + int m_sel; + const StringList& m_groupList; + + BOOL OnOK(UINT msg, WPARAM wp, LPARAM lp); + BOOL OnCancel(UINT msg, WPARAM wp, LPARAM lp); +}; + +#endif // DIALOG_H diff --git a/groupexplode/main.cpp b/groupexplode/main.cpp new file mode 100644 index 0000000..dbee433 --- /dev/null +++ b/groupexplode/main.cpp @@ -0,0 +1,82 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +static const char rcs_id[]="$Id$"; + +#include "mingwms.h" +#include "msLib.h" + +#include "dialog.h" + +// ---------------------------------------------------------------------- +// MINGW WRAPPER FUNCTIONS +// +static const char* GetTitle() +{ + return "Group Exploder"; +} + +static int Execute(msModel* model) +{ + W32DLib::Common::Initialise(); + W32DLib::Common::MessageTitle("Group Exploder"); + + // Unfortunately this is the best you can hope for with Milkshape... + // + HWND parent=GetForegroundWindow(); + + if (!model) + { + return -1; + } + + if (msModel_GetMeshCount(model)<1) + { + W32DLib::Common::Error(parent,NULL,"No meshes in the model!"); + return 0; + } + + StringList grps; + + for(int m=0;m<model->nNumMeshes;m++) + { + msMesh *mesh=model->pMeshes+m; + + grps.push_back(mesh->szName); + } + + + Dialog dlg(grps); + + if (dlg.ShowModal(W32DLib::Common::GetInstance(),parent)==IDOK) + { + int sel=dlg.GetSelectedGroup(); + } + + return 1; +} + +PLUGIN_SPEC void* CreatePlugIn() +{ + return CreateMINGWPlugin(MS_TYPE_TOOL, GetTitle, Execute); +} + + +// END OF FILE diff --git a/groupexplode/resource.h b/groupexplode/resource.h new file mode 100644 index 0000000..1da17e5 --- /dev/null +++ b/groupexplode/resource.h @@ -0,0 +1,30 @@ +// +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#define GR_DIALOG 1 + +#define IDC_STATIC 2 +#define IDC_OKBUT 3 +#define IDC_CANCELBUT 4 +#define IDC_GROUP 5 +#define IDC_RMORIG 6 diff --git a/groupexplode/resource.rc b/groupexplode/resource.rc new file mode 100644 index 0000000..31ddf19 --- /dev/null +++ b/groupexplode/resource.rc @@ -0,0 +1,17 @@ +#include <windows.h> +#include "resource.h" + +GR_DIALOG DIALOG 100, 100, 200, 85 + STYLE WS_POPUP | WS_BORDER + CAPTION "Group Exploder" + FONT 8,"MS Shell Dlg" +{ + LTEXT "Select group to explode:", IDC_STATIC, 10, 10, 180, 12 + + COMBOBOX IDC_GROUP, 10, 20, 180, 200, CBS_DROPDOWNLIST | WS_TABSTOP + + AUTOCHECKBOX "Remove Original Group", IDC_RMORIG, 10,40,180,18 + + PUSHBUTTON "OK", IDC_OKBUT, 10,60,80,18 + PUSHBUTTON "Cancel", IDC_CANCELBUT, 110,60,80,18 +} diff --git a/opengl/GNUmakefile b/opengl/GNUmakefile index bedb0b9..700fb6d 100644 --- a/opengl/GNUmakefile +++ b/opengl/GNUmakefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: GNUmakefile,v 1.2 2005-04-17 01:53:15 ianc Exp $ +# $Id: GNUmakefile,v 1.3 2005-04-18 01:01:56 ianc Exp $ # include ../make.conf @@ -40,8 +40,6 @@ OBJECTS = $(SOURCES:.cpp=.o) $(RES).o OUTDLL = $(TARGET).dll -OUTLIB = $(TARGET).a - WRAPPER = ../wrapper DLLLIBS = $(WRAPPER)/mingwms.lib $(MILKSHAPE)/lib/msModelLib.lib \ @@ -52,14 +50,14 @@ FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) -Wall `w32dlib-config --cflags` \ $(OUTDLL): $(OBJECTS) - dllwrap --output-lib=$(OUTLIB) --dllname=$(OUTDLL) \ + dllwrap --dllname=$(OUTDLL) \ --driver-name=c++ $(OBJECTS) $(DLLLIBS) # Unfortunately the windres resource compiler doesn't like my RC, so you # need RC.EXE from the Platform SDK to compile it to a RES first. # $(RES).o: $(RES).res - windres -v -i $(RES).res -o $(RES).o + windres -i $(RES).res -o $(RES).o $(RES).res: $(RES).rc $(RES).h rc $(RES).rc @@ -70,7 +68,7 @@ $(RES).res: $(RES).rc $(RES).h -include depend.mak clean: - -rm -f $(OUTDLL) $(OUTLIB) $(OBJECTS) $(RES).res + -rm -f $(OUTDLL) $(OBJECTS) $(RES).res depend: @echo Dependencies updated.... diff --git a/opengl/dialog.rc b/opengl/dialog.rc index 9399f20..731a865 100644 --- a/opengl/dialog.rc +++ b/opengl/dialog.rc @@ -1,7 +1,7 @@ #include <windows.h> #include "dialog.h" -GL_DIALOG DIALOG 0, 0, 337, 181 +GL_DIALOG DIALOG 100, 100, 337, 181 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION CAPTION "OpenGL Export" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US diff --git a/opengl/generate.cpp b/opengl/generate.cpp index 94403c8..33d2f13 100644 --- a/opengl/generate.cpp +++ b/opengl/generate.cpp @@ -81,15 +81,15 @@ std::string Generate::Info() return str.str(); } -void Generate::MakeFiles() +void Generate::MakeFiles(HWND parent) { if (m_blitzMax) { - GenerateBlitzMax(); + GenerateBlitzMax(parent); } else { - GenerateC(); + GenerateC(parent); } } @@ -211,7 +211,7 @@ void Generate::CalcModelBounds() } -void Generate::GenerateC() +void Generate::GenerateC(HWND parent) { std::FILE *fp; int len; @@ -236,7 +236,7 @@ void Generate::GenerateC() // if (!(fp=fopen(fname_h.c_str(),"w"))) { - W32DLib::Common::Error(0,0,"Couldn't create header file"); + W32DLib::Common::Error(parent,0,"Couldn't create header file"); return; } @@ -301,7 +301,7 @@ void Generate::GenerateC() // if (!(fp=fopen(fname_c.c_str(),"w"))) { - W32DLib::Common::Error(0,0,"Couldn't create source file"); + W32DLib::Common::Error(parent,0,"Couldn't create source file"); return; } @@ -413,12 +413,12 @@ void Generate::GenerateC() missing="The following meshes had no material:\n\n"+missing; missing+="\n\nThey were given the colour white."; - W32DLib::Common::Message(0,0,missing); + W32DLib::Common::Message(parent,0,missing); } } -void Generate::GenerateBlitzMax() +void Generate::GenerateBlitzMax(HWND parent) { std::FILE *fp; int len; @@ -443,7 +443,7 @@ void Generate::GenerateBlitzMax() // if (!(fp=fopen(fname_h.c_str(),"w"))) { - W32DLib::Common::Error(0,0,"Couldn't create header file"); + W32DLib::Common::Error(parent,0,"Couldn't create header file"); return; } @@ -508,7 +508,7 @@ void Generate::GenerateBlitzMax() // if (!(fp=fopen(fname_c.c_str(),"w"))) { - W32DLib::Common::Error(0,0,"Couldn't create source file"); + W32DLib::Common::Error(parent,0,"Couldn't create source file"); return; } @@ -620,7 +620,7 @@ void Generate::GenerateBlitzMax() missing="The following meshes had no material:\n\n"+missing; missing+="\n\nThey were given the colour white."; - W32DLib::Common::Message(0,0,missing); + W32DLib::Common::Message(parent,0,missing); } } diff --git a/opengl/generate.h b/opengl/generate.h index f7f07df..c8127a8 100644 --- a/opengl/generate.h +++ b/opengl/generate.h @@ -23,6 +23,7 @@ #ifndef GENERATE_H #define GENERATE_H +#include <windows.h> #include <string> #include <msLib.h> @@ -42,7 +43,7 @@ public: bool forceCOG, bool blitzMax); - void MakeFiles(); + void MakeFiles(HWND parent); std::string Info(); @@ -75,8 +76,8 @@ private: void CalcModelBounds(); - void GenerateC(); - void GenerateBlitzMax(); + void GenerateC(HWND parent); + void GenerateBlitzMax(HWND parent); }; #endif // GENERATE_H diff --git a/opengl/main.cpp b/opengl/main.cpp index 82bf991..7ded832 100644 --- a/opengl/main.cpp +++ b/opengl/main.cpp @@ -41,6 +41,10 @@ static int Execute(msModel* model) W32DLib::Common::Initialise(); W32DLib::Common::MessageTitle("Simple OpenGL"); + // Unfortunately this is the best you can hope for with Milkshape... + // + HWND parent=GetForegroundWindow(); + if (!model) { return -1; @@ -48,17 +52,17 @@ static int Execute(msModel* model) if (msModel_GetMeshCount(model)<1) { - W32DLib::Common::Error(NULL,NULL,"No meshes in the model!"); + W32DLib::Common::Error(parent,0,"No meshes in the model!"); return 0; } Generate gen(model); GLDialog dlg(gen); - if (dlg.ShowModal(W32DLib::Common::GetInstance(),NULL)==IDOK) + if (dlg.ShowModal(W32DLib::Common::GetInstance(),parent)==IDOK) { SetCursor(LoadCursor(NULL,IDC_WAIT)); - gen.MakeFiles(); + gen.MakeFiles(parent); SetCursor(LoadCursor(NULL,IDC_ARROW)); } |