Browse Source

Merge pull request #314 from Mystler/sdlbrowser

Toss plSDLBrowser -- Closes #1
Adam Johnson 12 years ago
parent
commit
a3ecf38636
  1. 1
      Sources/Plasma/PubUtilLib/CMakeLists.txt
  2. 99
      Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowser.rc
  3. 187
      Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlg.cpp
  4. 106
      Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlg.h
  5. 183
      Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlgHandlers.cpp
  6. 22
      Sources/Plasma/PubUtilLib/plSDLBrowser/resource.h

1
Sources/Plasma/PubUtilLib/CMakeLists.txt

@ -35,7 +35,6 @@ add_subdirectory(plProgressMgr)
add_subdirectory(plResMgr)
add_subdirectory(plScene)
add_subdirectory(plSDL)
#add_subdirectory(plSDLBrowser) # Not being used by any current slns
add_subdirectory(plSockets)
add_subdirectory(plStatGather)
add_subdirectory(plStatusLog)

99
Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowser.rc

@ -1,99 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG_SDLBROWSER DIALOG DISCARDABLE 0, 0, 372, 227
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "SDL Browser"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,189,50,14
PUSHBUTTON "Cancel",IDCANCEL,192,189,50,14
LTEXT "State Data Record",IDC_STATIC_SDREC,34,23,70,12
CONTROL "Values",IDC_STATIC_VALUELABEL,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,197,23,70,12
LISTBOX IDC_LIST_VAR,34,39,140,109,LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO_VALUE,197,39,140,109,CBS_SIMPLE | WS_VSCROLL |
WS_TABSTOP
CONTROL "Slider1",IDC_SLIDER_SDRECS,"msctls_trackbar32",
TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,34,158,140,9
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG_SDLBROWSER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 365
TOPMARGIN, 7
BOTTOMMARGIN, 220
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

187
Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlg.cpp

@ -1,187 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plSDLBrowserDlg.h"
#include "hsTemplates.h"
#include "../plSDL/plSDL.h"
// 'this' : used in base member initializer list
#pragma warning(disable:4355)
plSDLBrowserDlg::plSDLBrowserDlg(int inDialogId) :
plDialog(inDialogId) ,
fVarListBox(this,IDC_LIST_VAR),
fValueComboBox(this,IDC_COMBO_VALUE),
fOK(this,IDOK),
fCancel(this,IDCANCEL),
fSDRecSlider(this,IDC_SLIDER_SDRECS),
fCancelled(false),
fReadOnly(true),
fCurSDVar(nil),
fCurComboListBoxPos(-1),
fModified(false)
{
fVarListBox.SelectionChangeDelegate = plDelegate(this,(TDelegate)OnVarListSelChanged);
fVarListBox.DoubleClickDelegate = plDelegate(this,(TDelegate)OnVarListDoubleClicked);
fValueComboBox.fSelectionChangeDelegate= plDelegate(this,(TDelegate)OnValueComboSelChanged);
fValueComboBox.fEditUpdateDelegate= plDelegate(this,(TDelegate)OnValueComboEditChanged);
fOK.fClickDelegate = plDelegate(this,(TDelegate)OnOKClicked);
fCancel.fClickDelegate = plDelegate(this,(TDelegate)OnCancelClicked);
fSDRecSlider.fThumbPositionDelegate= plDelegate(this,(TDelegate)OnSDRecSliderChanged);
fSDRecSlider.fThumbTrackDelegate= plDelegate(this,(TDelegate)OnSDRecSliderChanged);
}
plSDLBrowserDlg::~plSDLBrowserDlg()
{
}
void plSDLBrowserDlg::SetDefaults()
{
}
plStateVariable* plSDLBrowserDlg::IGetListBoxVar(int cur)
{
plStateDataRecord* sdRec=IGetCurrentStateDataRec();
plStateVariable* var = (plStateVariable*)fVarListBox.GetItemData(cur); // sometimes doesn't work?
if (!var)
{
if (!IAtTopLevel())
cur++;
if (cur<sdRec->GetNumVars())
var=sdRec->GetVar(cur);
else
{
cur-=sdRec->GetNumVars();
var=sdRec->GetSDVar(cur);
}
}
return var;
}
int plSDLBrowserDlg::Run()
{
SetDefaults();
int ret=DoModal();
if (ret<0)
{
hsAssert(false, hsTempString(kFmtCtor, "SDL Browser dialog failed to initialize, err code %d, GetLastError %d",
ret, GetLastError()));
return hsFail;
}
return ret;
}
plStateDataRecord* plSDLBrowserDlg::IPopStateDataRec()
{
plStateDataRecord* sd=IGetCurrentStateDataRec();
fStateDataRecStack.pop_back();
return sd;
}
void plSDLBrowserDlg::IAddListBoxVar(plStateVariable* var, int cnt)
{
std::string s;
s = s + (char*)hsTempString(kFmtCtor, "%s[",var->GetVarDescriptor()->GetName());
if (var->GetVarDescriptor()->GetCount())
s = s + (char*)hsTempString(kFmtCtor, "%d",var->GetVarDescriptor()->GetCount());
s = s + (char*)hsTempString(kFmtCtor, "], %s",var->GetVarDescriptor()->GetTypeString());
fVarListBox.AddString(s.c_str());
fVarListBox.SetItemData(cnt, var);
hsAssert(var==fVarListBox.GetItemData(cnt), "set item data failed");
hsStatusMessageF("%s\n", s.c_str());
}
void plSDLBrowserDlg::IPopulateVarListBox(plStateDataRecord* sd)
{
fVarListBox.Empty();
if (!sd)
return;
hsTempString title(kFmtCtor, "SDL Browser - %s, version %d",
sd->GetDescriptor()->GetName(), sd->GetDescriptor()->GetVersion());
SetText(title);
int i, cnt=0;
if (!IAtTopLevel())
{
fVarListBox.AddString("..");
fVarListBox.SetItemData(cnt, IGetPreviousStateDataRec());
cnt++;
}
for (i=0;i<sd->GetNumVars(); i++, cnt++)
{
plSimpleStateVariable* var=sd->GetVar(i);
IAddListBoxVar(var, cnt);
}
for (i=0;i<sd->GetNumSDVars(); i++, cnt++)
{
plSDStateVariable* var=sd->GetSDVar(i);
IAddListBoxVar(var, cnt);
}
}
void plSDLBrowserDlg::IPopulateValueComboBox(plSimpleStateVariable* var)
{
fValueComboBox.Empty();
int i;
for(i=0;i<var->GetCount(); i++)
{
fValueComboBox.AddString((char*)hsTempString(var->GetAsString(i)));
}
}
plStateDataRecord* plSDLBrowserDlg::IGetPreviousStateDataRec() const
{
SDRecStack::const_iterator it=fStateDataRecStack.end();
it--; // last
it--; // 2nd to last
return *it;
}

106
Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlg.h

@ -1,106 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plSDLBrowserDLG_inc
#define plSDLBrowserDLG_inc
#include "resource.h"
#include "../plWndCtrls/plWndCtrls.h"
#include <vector>
class plSimpleStateVariable;
class plStateDataRecord;
class plStateVariable;
class plSDStateVariable;
class plSDLBrowserDlg : public plDialog
{
private:
bool fCancelled;
bool fModified;
bool fReadOnly;
plListBox fVarListBox;
plComboBox fValueComboBox;
plButton fOK, fCancel;
plTrackBar fSDRecSlider;
plSDStateVariable* fCurSDVar;
int fCurComboListBoxPos;
typedef std::vector<plStateDataRecord*> SDRecStack;
SDRecStack fStateDataRecStack;
plStateDataRecord* IGetCurrentStateDataRec() const { return fStateDataRecStack.back(); }
plStateDataRecord* IGetPreviousStateDataRec() const;
bool IAtTopLevel() const { return fStateDataRecStack.size()==1; }
void IPushStateDataRec(plStateDataRecord* sd) { fStateDataRecStack.push_back(sd); }
plStateDataRecord* IPopStateDataRec();
void IPopulateVarListBox(plStateDataRecord* sd) ;
void IAddListBoxVar(plStateVariable* var, int cnt);
void IPopulateValueComboBox(plSimpleStateVariable* var) ;
plStateVariable* IGetListBoxVar(int cur);
public:
DECLARE_WINDOWCLASS(plSDLBrowserDialog, plDialog);
plSDLBrowserDlg(int inDialogId=IDD_DIALOG_SDLBROWSER);
~plSDLBrowserDlg();
int Run();
// callbacks
void OnInitDialog();
void OnVarListSelChanged();
void OnVarListDoubleClicked();
void OnValueComboSelChanged();
void OnValueComboEditChanged();
void OnOKClicked();
void OnCancelClicked();
void OnSDRecSliderChanged();
// setters
void SetReadOnly(bool r) { fReadOnly=r; }
void SetStateDataRec(plStateDataRecord* sd) { fStateDataRecStack.clear(); fStateDataRecStack.push_back(sd); }
void SetDefaults();
// getters
bool GetCancelled() const { return fCancelled; }
bool GetModified() const { return fModified; }
};
#endif // plSDLBrowserDLG_inc

183
Sources/Plasma/PubUtilLib/plSDLBrowser/plSDLBrowserDlgHandlers.cpp

@ -1,183 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plSDLBrowserDlg.h"
#include "../plSDL/plSDL.h"
void plSDLBrowserDlg::OnInitDialog()
{
plDialog::OnInitDialog();
const int kWinPos=250;
plRect r=GetWindowRect();
r.Min.X+=kWinPos;
r.Min.Y+=kWinPos;
r.Max.X+=kWinPos;
r.Max.Y+=kWinPos;
MoveWindow(r, true);
fSDRecSlider.Hide();
if (IGetCurrentStateDataRec())
IPopulateVarListBox(IGetCurrentStateDataRec());
}
void plSDLBrowserDlg::OnOKClicked()
{
EndDialogTrue();
}
void plSDLBrowserDlg::OnCancelClicked()
{
EndDialogFalse();
fCancelled=true;
}
void plSDLBrowserDlg::OnVarListSelChanged()
{
int cur=fVarListBox.GetCurrent();
std::string curString=fVarListBox.GetString(cur);
if (curString=="..")
return;
plStateVariable* var=IGetListBoxVar(cur);
hsAssert(var, "nil var?");
if (var->GetAsSimpleStateVar())
{
plSimpleStateVariable* sVar=var->GetAsSimpleStateVar();
IPopulateValueComboBox(sVar);
fValueComboBox.SetCurrent(0);
fCurComboListBoxPos=0;
}
}
void plSDLBrowserDlg::OnVarListDoubleClicked()
{
fCurSDVar=nil;
fSDRecSlider.Hide();
int cur=fVarListBox.GetCurrent();
std::string curString=fVarListBox.GetString(cur);
if (curString=="..")
{
IPopStateDataRec();
IPopulateVarListBox(IGetCurrentStateDataRec());
return;
}
plStateVariable* var=IGetListBoxVar(cur);
hsAssert(var, "nil var?");
if (var->GetAsSDStateVar())
{
// user doubleclicked an SDVar
plSDStateVariable* sdVar=var->GetAsSDStateVar();
if (sdVar->GetCount()==0)
{
sdVar->Resize(1);
}
else
if (sdVar->GetCount()>1)
{
fSDRecSlider.Show();
int max=var->GetCount();
fSDRecSlider.SetRange(0, max-1);
}
IPushStateDataRec(sdVar->GetStateDataRecord(0));
IPopulateVarListBox(IGetCurrentStateDataRec());
fCurSDVar=sdVar;
fValueComboBox.Empty();
}
}
void plSDLBrowserDlg::OnValueComboSelChanged()
{
int cur=fValueComboBox.GetCurrent();
hsStatusMessageF("Changing cur combo box sel to %d\n", cur);
if (cur>=0)
fCurComboListBoxPos=cur;
}
void plSDLBrowserDlg::OnValueComboEditChanged()
{
if (fReadOnly)
return;
// get var from list box
int listBoxPos=fVarListBox.GetCurrent();
plStateVariable* var=IGetListBoxVar(listBoxPos);
hsAssert(var, "nil var?");
hsAssert(var->GetAsSimpleStateVar(), "wrong type of var");
// change value of var
int comboxBoxPos=fValueComboBox.GetCurrent();
if (comboxBoxPos<0)
comboxBoxPos=fCurComboListBoxPos;
if (comboxBoxPos>=0)
{
std::string editString=fValueComboBox.GetText();
if (var->GetAsSimpleStateVar()->SetFromString(editString.c_str(), comboxBoxPos))
{
hsStatusMessageF("changing item %d to %s", comboxBoxPos, editString.c_str());
fValueComboBox.InsertString(comboxBoxPos, editString.c_str());
fValueComboBox.DeleteString(comboxBoxPos+1);
var->GetAsSimpleStateVar()->SetDirty(true);
var->GetAsSimpleStateVar()->SetUsed(true);
}
#if 0
editString.reverse();
fValueComboBox.SetText(editString.c_str());
#endif
}
fModified=true;
}
void plSDLBrowserDlg::OnSDRecSliderChanged()
{
int pos=fSDRecSlider.GetPos();
IPopStateDataRec();
IPushStateDataRec(fCurSDVar->GetStateDataRecord(pos));
IPopulateVarListBox(IGetCurrentStateDataRec());
fValueComboBox.Empty();
hsStatusMessageF("Slider pos=%d\n", pos);
}

22
Sources/Plasma/PubUtilLib/plSDLBrowser/resource.h

@ -1,22 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by plSDLBrowser.rc
//
#define IDD_DIALOG_SDLBROWSER 201
#define IDC_STATIC_VARLABEL 2000
#define IDC_STATIC_SDREC 2001
#define IDC_STATIC_VALUELABEL 2002
#define IDC_LIST_VAR 2003
#define IDC_COMBO_VALUE 2004
#define IDC_SLIDER_SDRECS 2005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 202
#define _APS_NEXT_COMMAND_VALUE 41001
#define _APS_NEXT_CONTROL_VALUE 2006
#define _APS_NEXT_SYMED_VALUE 202
#endif
#endif
Loading…
Cancel
Save