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 /groupexplode | |
parent | 14123d8051df5cbae0331c28f63a8ec3ef9a3852 (diff) |
Added core of group explode. Also fixed modal windows as well as can be done with MS.
Diffstat (limited to 'groupexplode')
-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 |
9 files changed, 460 insertions, 0 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 +} |