svn -> git Migration

This commit is contained in:
KimLS
2013-02-16 16:14:39 -08:00
parent 88c9715fb0
commit da7347f76f
1174 changed files with 445622 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EQEmuWxProject", "EQEmuWxProject.vcproj", "{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}.Debug.ActiveCfg = Debug|Win32
{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}.Debug.Build.0 = Debug|Win32
{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}.Release.ActiveCfg = Release|Win32
{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
+170
View File
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="EQEmuWxProject"
ProjectGUID="{5D3FC402-F6D9-49B7-8ABF-18F66E91AB6B}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/EQEmuWxProject.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/EQEmuWxProject.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libmysql.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib"
OutputFile="$(OutDir)/TaskMaster.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="C:\Documents and Settings\Golgie\My Documents\wxWidgets\wxWidgets-2.8.9\lib\vc_lib"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\activities.cpp">
</File>
<File
RelativePath=".\base.cpp">
</File>
<File
RelativePath=".\base_utility.cpp">
</File>
<File
RelativePath=".\ErrorLog.cpp">
</File>
<File
RelativePath=".\goals.cpp">
</File>
<File
RelativePath=".\proximity.cpp">
</File>
<File
RelativePath=".\tasks.cpp">
</File>
<File
RelativePath=".\utility.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\base.h">
</File>
<File
RelativePath=".\ErrorLog.h">
</File>
<File
RelativePath=".\items.h">
</File>
<File
RelativePath=".\tasks.h">
</File>
<File
RelativePath=".\utility.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+71
View File
@@ -0,0 +1,71 @@
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
#include "ErrorLog.h"
EQEmuErrorLog::EQEmuErrorLog()
{
mErrorLog = NULL;
mErrorLog = fopen(LOG_FILE_NAME, "w");
if(!mErrorLog) {
Log(eqEmuLogConsole,"Opening of %s for writing failed, debug output will be tied to console only.", LOG_FILE_NAME);
}
else
Log(eqEmuLogBoth, "EQEmuErrorLog Init Successful.");
mErrorLogSQL = NULL;
mErrorLogSQL = fopen(SQL_LOG_FILE_NAME, "a");
if(!mErrorLog) {
Log(eqEmuLogConsole, "SQL Log Init FAILED, %s could not be opened for writing", SQL_LOG_FILE_NAME);
}
else
{
Log(eqEmuLogConsole, "SQL Log Init Complete");
}
}
EQEmuErrorLog::~EQEmuErrorLog()
{
Log(eqEmuLogBoth, "EQEmuErrorLog Shutdown.");
if(mErrorLog) {
fclose(mErrorLog);
mErrorLog = NULL;
}
}
void EQEmuErrorLog::Log(unsigned int mOutputType, const char *msg, ...)
{
va_list argptr;
char *buffer = new char[MAX_LOG_LEN];
va_start(argptr, msg);
_vsnprintf(buffer, MAX_LOG_LEN, msg, argptr);
va_end(argptr);
time_t mClock;
struct tm *mTime;
time(&mClock);
mTime = localtime(&mClock);
if(mOutputType & eqEmuLogConsole){
printf("[Debug] [%02d.%02d.%02d - %02d:%02d:%02d] %s\n", mTime->tm_mon+1, mTime->tm_mday, mTime->tm_year%100, mTime->tm_hour, mTime->tm_min, mTime->tm_sec, buffer);
}
if(mOutputType & eqEmuLogFile){
if(mErrorLog){
fprintf(mErrorLog, "[%02d.%02d.%02d - %02d:%02d:%02d] %s\n", mTime->tm_mon+1, mTime->tm_mday, mTime->tm_year%100, mTime->tm_hour, mTime->tm_min, mTime->tm_sec, buffer);
}
}
if(mOutputType & eqEmuLogSQL)
{
if(mErrorLogSQL){
fprintf(mErrorLogSQL, "# [%02d.%02d.%02d - %02d:%02d:%02d]\n", mTime->tm_mon+1, mTime->tm_mday, mTime->tm_year%100, mTime->tm_hour, mTime->tm_min, mTime->tm_sec);
fprintf(mErrorLogSQL, "%s;\n\n", buffer);
}
}
if(buffer)
delete[] buffer;
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef EQWX_ERRORLOG__H
#define EQWX_ERRORLOG__H
#include <stdio.h>
#include <stdarg.h>
//Log options
enum{
eqEmuLogConsole = 1,
eqEmuLogFile = 2,
eqEmuLogSQL = 4,
eqEmuLogBoth = (eqEmuLogConsole | eqEmuLogFile),
};
//log file output
#define LOG_FILE_NAME "debug.txt"
#define SQL_LOG_FILE_NAME "sql_log.sql"
//max single log length
//same as a client:message() max len
#define MAX_LOG_LEN 4096
//much simplified logging function, similar to the one used on the server (Tho much simpler)
class EQEmuErrorLog {
public:
EQEmuErrorLog();
~EQEmuErrorLog();
void Log(unsigned int mOutputType, const char *msg, ...);
private:
FILE* mErrorLog;
FILE* mErrorLogSQL;
};
#endif
+648
View File
@@ -0,0 +1,648 @@
#include <wx/wx.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
void MainFrame::ActivitiesListBoxSimpleSelect(wxCommandEvent& event)
{
eqtask_activity_id *eqaid;
eqaid = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(event.GetInt());
if(eqaid){
}
else{
mErrorLog->Log(eqEmuLogBoth, "Error selected a NULL activity object!");
}
}
void MainFrame::ActivitiesListBoxDoubleClick(wxCommandEvent& event)
{
eqtask_activity_id *eqaid;
eqaid = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(event.GetInt());
if(eqaid){
openedActivity.activityid = eqaid->activityid;
openedActivity.id = eqaid->id;
openedActivity.step = eqaid->step;
FillActivity(eqaid->id, eqaid->activityid, eqaid->step);
mActText1->Enable();
mActText2->Enable();
mActText3->Enable();
mActivityZone->Enable();
mActivityOptional->Enable();
mActID->Enable();
mActStep->Enable();
mActType->Enable();
mActDeliver->Enable();
mActMethod->Enable();
mActGoalID->Enable();
mActGoalCount->Enable();
}
else{
mErrorLog->Log(eqEmuLogBoth, "Error double clicked a NULL activity object!");
}
}
void MainFrame::NewActivity(wxCommandEvent& event)
{
if(!mMysql)
return;
if(openedIndex == -1)
return;
mErrorLog->Log(eqEmuLogBoth, "Creating new activity...");
eqtask_activities newAct;
eqtask curTask;
mErrorLog->Log(eqEmuLogBoth, "Opened Index %u", openedIndex);
vector<eqtask>::iterator tIter = taskList.begin();
tIter += openedIndex;
curTask = *tIter;
vector<eqtask_activities>::iterator Iter;
unsigned int highestId = 0;
bool zeroExists;
if(!taskActivitiesList.empty()){
for(Iter = taskActivitiesList.begin(); Iter != taskActivitiesList.end(); Iter++)
{
eqtask_activities curAct = *Iter;
if(curAct.id == curTask.id){
if(curAct.activityId == 0)
zeroExists = true;
if(curAct.activityId > highestId){
highestId = curAct.activityId;
}
}
}
}
mErrorLog->Log(eqEmuLogBoth, "Highest id: %u", highestId);
if(highestId == 0)
{
if(zeroExists)
{
newAct.activityId = highestId+1;
}
else
{
newAct.activityId = 0;
}
}
else
{
newAct.activityId = highestId+1;
}
newAct.id = curTask.id;
newAct.zoneid = curTask.startzone;
newAct.activityType = 0;
newAct.deliverToNpc = 0;
newAct.goalcount = 0;
newAct.goalid = 0;
newAct.goalmethod = 2;
newAct.optional = false;
newAct.step = 0;
strcpy(newAct.text1, "");
strcpy(newAct.text2, "");
strcpy(newAct.text3, "");
taskActivitiesList.push_back(newAct);
eqtask_activity_id * eqaid = new eqtask_activity_id;
eqaid->id = newAct.id;
eqaid->step = 0;
eqaid->activityid = newAct.activityId;
wxString taskStr;
taskStr.Printf("Step: %u", 0);
ActivitiesSelectionList->Append(taskStr, (void*)eqaid);
taskStr.clear();
if(mMysql){
char * mActQuery = 0;
MakeAnyLenString(&mActQuery, "INSERT INTO `activities` (`taskid`,`activityid`,`step`,`activitytype`,`text1`,`text2`,`text3`,`goalid`,`goalmethod`,`goalcount`,`delivertonpc`,`zoneid`,`optional`) VALUES (%u,%u,%u,%u,'%s','%s','%s',%u,%u,%u,%u,%u,%u)",
newAct.id, newAct.activityId, newAct.step, newAct.activityType, newAct.text1, newAct.text2, newAct.text3, newAct.goalid, newAct.goalmethod, newAct.goalcount, newAct.deliverToNpc, newAct.zoneid, newAct.optional );
mErrorLog->Log(eqEmuLogSQL, "%s", mActQuery);
if (mysql_query(mMysql, mActQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
}
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql not connected for activity creation.");
}
}
void MainFrame::DeleteActivity(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Mysql not connected for delete activity");
return;
}
if(ActivitiesSelectionList->GetCount() == 0){
mErrorLog->Log(eqEmuLogBoth, "No activities in list to select for delete");
return;
}
int reply = wxMessageBox("Are you sure?", "Confirm Delete", wxYES_NO, this);
if(reply != wxYES)
{
mErrorLog->Log(eqEmuLogBoth, "User aborted delete of activity.");
return;
}
eqtask_activity_id *selAct = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(ActivitiesSelectionList->GetSelection());
unsigned int aid = selAct->activityid;
unsigned int tid = selAct->id;
if(selAct)
{
if(mMysql){
char * mActQuery = 0;
MakeAnyLenString(&mActQuery, "DELETE FROM activities WHERE taskid=%u AND activityid=%u",selAct->id, selAct->activityid);
mErrorLog->Log(eqEmuLogSQL, "%s", mActQuery);
if (mysql_query(mMysql, mActQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
}
else{
mErrorLog->Log(eqEmuLogBoth, "No mysql connection for delete");
}
for(unsigned int i = 0; i < ActivitiesSelectionList->GetCount(); i++)
{
eqtask_activity_id * id = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(i);
if(id){
if(id->activityid == selAct->activityid && id->id == selAct->id)
{
if(openedActivity.activityid == selAct->activityid && openedActivity.id == selAct->id)
{
mActText1->Clear();
mActText1->Disable();
mActText2->Clear();
mActText2->Disable();
mActText3->Clear();
mActText3->Disable();
mActivityZone->Select(0);
mActivityZone->Disable();
mActivityOptional->SetValue(false);
mActivityOptional->Disable();
mActID->Clear();
mActID->Disable();
mActStep->Clear();
mActStep->Disable();
mActType->Select(0);
mActType->Disable();
mActDeliver->Clear();
mActDeliver->Disable();
mActMethod->Select(2);
mActMethod->Disable();
mActGoalID->Clear();
mActGoalID->Disable();
mActGoalCount->Clear();
mActGoalCount->Disable();
}
mErrorLog->Log(eqEmuLogBoth, "Erasing Activity Selection");
ActivitiesSelectionList->Delete(i);
delete id;
mErrorLog->Log(eqEmuLogBoth, "Erased..");
break;
}
}
}
vector<eqtask_activities>::iterator Iter;
for(Iter = taskActivitiesList.begin(); Iter!=taskActivitiesList.end(); Iter++)
{
eqtask_activities curAct = *Iter;
if(curAct.activityId == aid && curAct.id == tid){
mErrorLog->Log(eqEmuLogBoth, "Erasing Activity Iterator");
taskActivitiesList.erase(Iter);
mErrorLog->Log(eqEmuLogBoth, "Erased..");
break;
}
}
}
else
{
mErrorLog->Log(eqEmuLogBoth, "No activity selected for delete.");
}
}
void MainFrame::PopulateActivities()
{
int taskId = -1;
mErrorLog->Log(eqEmuLogBoth, "Populating activities...");
vector<eqtask>::iterator Iter;
int index = 0;
for(Iter = taskList.begin(); Iter != taskList.end(); Iter++)
{
if(index == openedIndex){
eqtask eqt = *Iter;
taskId = eqt.id;
break;
}
index++;
}
if(taskId > -1){
vector<eqtask_activities>::iterator aIter;
for(aIter = taskActivitiesList.begin(); aIter != taskActivitiesList.end(); aIter++)
{
eqtask_activities eqta = *aIter;
if(eqta.id == taskId){
eqtask_activity_id * eqaid = new eqtask_activity_id;
eqaid->id = eqta.id;
eqaid->step = eqta.step;
eqaid->activityid = eqta.activityId;
wxString taskStr;
taskStr.Printf("Step: %u", eqta.step);
ActivitiesSelectionList->Append(taskStr, (void*)eqaid);
taskStr.clear();
}
}
}
}
void MainFrame::ClearActivities()
{
mErrorLog->Log(eqEmuLogBoth, "Clearing activities...");
for(unsigned int x = 0; x < ActivitiesSelectionList->GetCount(); x++)
{
eqtask_activity_id *eqaid = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(x);
if(eqaid)
{
mErrorLog->Log(eqEmuLogBoth, "Delete of activity index: %u (%u:%u)", x, eqaid->id, eqaid->step);
delete eqaid;
eqaid = NULL;
}
}
ActivitiesSelectionList->Clear();
}
void MainFrame::FillActivity(int id, int activityid, int step)
{
if(id > -1){
vector<eqtask_activities>::iterator Iter;
for(Iter = taskActivitiesList.begin(); Iter != taskActivitiesList.end();Iter++)
{
eqtask_activities eqta = *Iter;
if(eqta.id == id && eqta.activityId == activityid && eqta.step == step)
{
wxString actStr;
actStr.Clear();
actStr.Printf("%s", eqta.text1);
mActText1->Clear();
mActText1->AppendText(actStr);
actStr.Clear();
actStr.Printf("%s", eqta.text2);
mActText2->Clear();
mActText2->AppendText(actStr);
actStr.Clear();
actStr.Printf("%s", eqta.text3);
mActText3->Clear();
mActText3->AppendText(actStr);
actStr.Clear();
SetZoneSelectionByIdActivity(eqta.zoneid);
mActivityOptional->SetValue(eqta.optional);
actStr.Printf("%u", eqta.activityId);
mActID->Clear();
mActID->AppendText(actStr);
actStr.Clear();
actStr.Printf("%u", eqta.step);
mActStep->Clear();
mActStep->AppendText(actStr);
actStr.Clear();
actStr.Printf("%u", eqta.deliverToNpc);
mActDeliver->Clear();
mActDeliver->AppendText(actStr);
actStr.Clear();
actStr.Printf("%u", eqta.goalid);
mActGoalID->Clear();
mActGoalID->AppendText(actStr);
actStr.Clear();
actStr.Printf("%u", eqta.goalcount);
mActGoalCount->Clear();
mActGoalCount->AppendText(actStr);
actStr.Clear();
if(eqta.goalmethod >= 0 && eqta.goalmethod <= 2)
mActMethod->Select(eqta.goalmethod);
else
mActMethod->Select(2);
if(eqta.activityType > 0 && eqta.activityType < 12)
{
mActType->Select(eqta.activityType);
}
else
{
if(eqta.activityType == 100){
mActType->Select(12);
}
else if(eqta.activityType == 999)
{
mActType->Select(13);
}
else{
mActType->Select(0);
}
}
wxCommandEvent evnt;
evnt.SetInt(eqta.activityType);
ActivityChoiceChange(evnt);
return;
}
}
}
}
void MainFrame::ActivityChoiceChange(wxCommandEvent& event)
{
mErrorLog->Log(eqEmuLogBoth, "Activity Choice Change: %u", event.GetInt());
switch(event.GetInt()){
case 1:
mActInfoText->SetLabel("Deliver:\nDeliver a number of items to a NPC\n"
"text1: NPC Name\n"
"text2: Item Name"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 2:
mActInfoText->SetLabel("Kill:\nKill a number of NPCs\n"
"text1: NPC Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 3:
mActInfoText->SetLabel("Loot:\nLoot a number of items\n"
"text1: Item Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 4:
mActInfoText->SetLabel("Speak To:\nSpeak with a specific NPC\n"
"text1: NPC Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 5:
mActInfoText->SetLabel("Explore:\nExplore a certain area of the game\n"
"text1: Area Description\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 6:
mActInfoText->SetLabel("Tradeskill:\nCreate a number of items\n"
"text1: Item Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 7:
mActInfoText->SetLabel("Fish:\nObtain a number of items with fishing\n"
"text1: Item Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 8:
mActInfoText->SetLabel("Forage:\nObtain a number of items via foraging\n"
"text1: Item Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 11:
mActInfoText->SetLabel("Touch:\nEnter a certain zone\n"
"text1: Zone Name\n"
"\n\nRemember: text3 can be used to \noverwrite text1 or text2");
break;
case 10:
case 9:
mActInfoText->SetLabel("Use:\nNot currently in use\n");
break;
case 12:
mActInfoText->SetLabel("Give Cash:\nGive money to a certain npc\n"
"text3: Custom Description");
break;
case 13:
mActInfoText->SetLabel("Custom:\nCustom task handled by the quest\nsystem\n"
"text3: Custom Description");
break;
default:
mActInfoText->SetLabel("Unknown Activity Type:\nThis is not a valid activity type");
break;
}
}
void MainFrame::SaveActivity(wxCommandEvent& event)
{
mErrorLog->Log(eqEmuLogBoth, "Save activity requested...");
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Mysql not connected for save activity");
return;
}
if(openedActivity.activityid < 0 || openedActivity.id < 0){
mErrorLog->Log(eqEmuLogBoth, "Activity not valid for save.");
return;
}
eqtask_activities ourAct;
vector<eqtask_activities>::iterator Iter;
for(Iter = taskActivitiesList.begin(); Iter != taskActivitiesList.end(); Iter++)
{
if((*Iter).activityId == openedActivity.activityid && (*Iter).id == openedActivity.id)
{
ourAct = *Iter;
break;
}
}
int delid = openedActivity.activityid;
bool canUpdate = false;
wxString getStr;
getStr = mActText1->GetValue();
strcpy(ourAct.text1, getStr.mb_str());
getStr.Clear();
getStr = mActText2->GetValue();
strcpy(ourAct.text2, getStr.mb_str());
getStr.Clear();
getStr = mActText3->GetValue();
strcpy(ourAct.text3, getStr.mb_str());
getStr.Clear();
int * i = (int*)mActivityZone->GetClientData(mActivityZone->GetSelection());
ourAct.zoneid = *i;
ourAct.optional = mActivityOptional->GetValue();
getStr = mActID->GetValue();
ourAct.activityId = atoi(getStr.mb_str());
getStr.Clear();
getStr = mActStep->GetValue();
ourAct.step = atoi(getStr.mb_str());
getStr.Clear();
int type = mActType->GetSelection();
if(type > 0 && type < 12){
ourAct.activityType = type;
}
else{
if(type == 12){
ourAct.activityType = 100;
}
else if(type == 13){
ourAct.activityType = 999;
}
else
ourAct.activityType = 0;
}
getStr = mActDeliver->GetValue();
ourAct.deliverToNpc = atoi(getStr.mb_str());
getStr.Clear();
ourAct.goalmethod = mActMethod->GetSelection();
getStr = mActGoalID->GetValue();
ourAct.goalid = atoi(getStr.mb_str());
getStr.Clear();
getStr = mActGoalCount->GetValue();
ourAct.goalcount = atoi(getStr.mb_str());
getStr.Clear();
if(ourAct.activityId == openedActivity.activityid && ourAct.id == openedActivity.id){
canUpdate = true;
mErrorLog->Log(eqEmuLogBoth, "Can use UPDATE.");
}
else{
mErrorLog->Log(eqEmuLogBoth, "Cannot use UPDATE must replace instead");
}
if(canUpdate)
{
char * mQuery = 0;
MakeAnyLenString(&mQuery, "UPDATE activities SET step=%u, activitytype=%u, text1='%s', text2='%s', text3='%s', goalid=%u, goalmethod=%u,goalcount=%u, delivertonpc=%u, zoneid=%u, optional=%u WHERE taskid=%u AND activityid =%u",
ourAct.step, ourAct.activityType, MakeStringSQLSafe(ourAct.text1).mb_str(), MakeStringSQLSafe(ourAct.text2).mb_str(), MakeStringSQLSafe(ourAct.text3).mb_str(), ourAct.goalid, ourAct.goalmethod, ourAct.goalcount, ourAct.deliverToNpc, ourAct.zoneid, ourAct.optional, ourAct.id, ourAct.activityId );
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
}
else
{
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM activities WHERE taskid=%u AND activityid=%u", ourAct.id, delid);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
MakeAnyLenString(&mQuery, "INSERT INTO `activities` (`taskid`,`activityid`,`step`,`activitytype`,`text1`,`text2`,`text3`,`goalid`,`goalmethod`,`goalcount`,`delivertonpc`,`zoneid`,`optional`) VALUES (%u,%u,%u,%u,'%s','%s','%s',%u,%u,%u,%u,%u,%u)",
ourAct.id, ourAct.activityId, ourAct.step, ourAct.activityType, MakeStringSQLSafe(ourAct.text1).mb_str(), MakeStringSQLSafe(ourAct.text2).mb_str(), MakeStringSQLSafe(ourAct.text3).mb_str(), ourAct.goalid, ourAct.goalmethod, ourAct.goalcount, ourAct.deliverToNpc, ourAct.zoneid, ourAct.optional);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
}
(*Iter).activityId = ourAct.activityId;
(*Iter).activityType = ourAct.activityType;
(*Iter).deliverToNpc = ourAct.deliverToNpc;
(*Iter).goalcount = ourAct.goalcount;
(*Iter).goalid = ourAct.goalid;
(*Iter).goalmethod = ourAct.goalmethod;
(*Iter).id = ourAct.id;
(*Iter).optional = ourAct.optional;
(*Iter).step = ourAct.step;
strcpy((*Iter).text1, ourAct.text1);
strcpy((*Iter).text2, ourAct.text2);
strcpy((*Iter).text3, ourAct.text3);
(*Iter).zoneid = ourAct.zoneid;
int ourIndex = 0;
for(unsigned int Index = 0 ;Index < ActivitiesSelectionList->GetCount(); Index++)
{
eqtask_activity_id *eqta;
eqta = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(Index);
if(eqta){
if(eqta->activityid == openedActivity.activityid && eqta->id == openedActivity.id){
ourIndex = Index;
break;
}
}
else{
mErrorLog->Log(eqEmuLogBoth, "NULL eqta, index %u", Index);
}
}
getStr.Clear();
getStr.Printf("Step: %u", (*Iter).step);
eqtask_activity_id * eqt = (eqtask_activity_id*)ActivitiesSelectionList->GetClientData(ourIndex);
eqt->activityid = ourAct.activityId;
eqt->id = ourAct.id;
eqt->step = ourAct.step;
ActivitiesSelectionList->SetString(ourIndex, getStr);
ActivitiesSelectionList->SetClientData(ourIndex, (void*)eqt);
openedActivity.activityid = ourAct.activityId;
openedActivity.id = ourAct.id;
openedActivity.step = ourAct.step;
mErrorLog->Log(eqEmuLogBoth, "Save finished.");
}
void MainFrame::ContextMenuActivityList()
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Context menu cannot open, not connected to db");
return;
}
wxMenu *mMenu;
mMenu = new wxMenu();
mMenu->Append(MENU_NewActivity, wxT("New Activity"), wxT("Creates a new activity"));
mMenu->Append(MENU_DeleteActivity, wxT("Delete Activity"), wxT("Deletes the selected activity"));
mMenu->AppendSeparator();
mMenu->Append(MENU_SaveActivity, wxT("Save Activity"), wxT("Saves the opened activity"));
PopupMenu(mMenu);
delete mMenu;
}
+672
View File
@@ -0,0 +1,672 @@
#include <wx/wx.h>
#include <wx/aboutdlg.h>
#include <wx/cmdline.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
//Defined Events
BEGIN_EVENT_TABLE ( MainFrame, wxFrame )
EVT_MENU(MENU_Connect, MainFrame::Connect)
EVT_MENU(MENU_Quit, MainFrame::Quit)
EVT_MENU(MENU_NewTask, MainFrame::NewTask)
EVT_MENU(MENU_DeleteTask, MainFrame::DeleteTask)
EVT_MENU(MENU_SaveTask, MainFrame::SaveTask)
EVT_MENU(MENU_NewActivity, MainFrame::NewActivity)
EVT_MENU(MENU_DeleteActivity, MainFrame::DeleteActivity)
EVT_MENU(MENU_SaveActivity, MainFrame::SaveActivity)
EVT_MENU(MENU_About, MainFrame::About)
EVT_LISTBOX_DCLICK(LIST_Click, MainFrame::ListBoxDoubleClick)
EVT_LISTBOX(LIST_Click, MainFrame::ListBoxSimpleSelect)
EVT_BUTTON(BUTTON_Reward, MainFrame::OnRewardButton )
EVT_LISTBOX_DCLICK(LIST_Click_Activities, MainFrame::ActivitiesListBoxDoubleClick)
EVT_LISTBOX(LIST_Click_Activities, MainFrame::ActivitiesListBoxSimpleSelect)
EVT_CHOICE(CHOICE_ActivityChoiceChange, MainFrame::ActivityChoiceChange)
EVT_CONTEXT_MENU(MainFrame::ContextClick)
EVT_LISTBOX_DCLICK(LIST_Click_Goals, MainFrame::GoalsListBoxDoubleClick)
EVT_MENU(MENU_NewGoal, MainFrame::NewGoal)
EVT_MENU(MENU_DeleteGoal, MainFrame::DeleteGoal)
EVT_MENU(MENU_AddGoalItem, MainFrame::NewGoalValue)
EVT_MENU(MENU_DeleteGoalItem, MainFrame::DeleteGoalValue)
EVT_MENU(MENU_ModifyGoalItem, MainFrame::ChangeGoalValue)
EVT_BUTTON(BUTTON_AddGoalItem, MainFrame::NewGoalValue)
EVT_BUTTON(BUTTON_DeleteGoalItem, MainFrame::DeleteGoalValue)
EVT_BUTTON(BUTTON_ModifyGoalItem, MainFrame::ChangeGoalValue)
EVT_MENU(MENU_NewProximity, MainFrame::NewProximity)
EVT_MENU(MENU_DeleteProximity, MainFrame::DeleteProximity)
EVT_MENU(MENU_SaveProximity, MainFrame::SaveProximity)
EVT_LISTBOX_DCLICK(LIST_Click_Proximity, MainFrame::ProximityListBoxDoubleClick)
END_EVENT_TABLE()
//Our main() thread
IMPLEMENT_APP_CONSOLE(MainApp)
bool MainApp::OnInit()
{
MainFrame *MainWin = new MainFrame(wxT("Task Master"), wxDefaultPosition, //wxPoint(1,1),
wxSize(800, 600)); // Create an instance of our frame, or window
MainWin->Show(TRUE); // show the window
SetTopWindow(MainWin);// and finally, set it as the main window
return TRUE;
}
MainFrame::MainFrame(const wxString& title,
const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *) NULL, -1, title, pos, size, (wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxSYSTEM_MENU|wxCLIP_CHILDREN|wxTAB_TRAVERSAL))
{
mErrorLog = new EQEmuErrorLog;
CreateStatusBar(1, 0);
mErrorLog->Log(eqEmuLogBoth, "Creating Menus.");
MainMenu = new wxMenuBar();
wxMenu *FileMenu = new wxMenu();
FileMenu->Append(MENU_Connect, wxT("&Connect"), wxT("Connect to the Database"));
FileMenu->AppendSeparator();
FileMenu->Append(MENU_Quit, wxT("&Quit"), wxT("Quit"));
MainMenu->Append(FileMenu, wxT("&Main"));
wxMenu *EditMenu = new wxMenu();
EditMenu->Append(MENU_NewTask, wxT("&New Task"), wxT("Creates a new task"));
EditMenu->Append(MENU_DeleteTask, wxT("&Delete Task"), wxT("Deletes the selected task"));
EditMenu->AppendSeparator();
EditMenu->Append(MENU_SaveTask, wxT("&Save Task"), wxT("Saves the opened task"));
MainMenu->Append(EditMenu, wxT("&Tasks"));
wxMenu *ActMenu = new wxMenu();
ActMenu->Append(MENU_NewActivity, wxT("&New Activity"), wxT("Create a new activity for this task"));
ActMenu->Append(MENU_DeleteActivity, wxT("&Delete Activity"), wxT("Deletes the selected activity for this task"));
ActMenu->AppendSeparator();
ActMenu->Append(MENU_SaveActivity, wxT("&Save Activity"), wxT("Saves the opened task activity"));
MainMenu->Append(ActMenu, wxT("&Activities"));
wxMenu *GoalsMenu = new wxMenu();
GoalsMenu->Append(MENU_NewGoal, wxT("&New Goal"), wxT("Creates a new goal list entry"));
GoalsMenu->Append(MENU_DeleteGoal, wxT("&Delete Goal"), wxT("Deletes the selected goal list entry"));
GoalsMenu->AppendSeparator();
GoalsMenu->Append(MENU_AddGoalItem, wxT("N&ew Goal Value"), wxT("Saves the opened task activity"));
GoalsMenu->Append(MENU_DeleteGoalItem, wxT("De&lete Goal Value"), wxT("Deletes the selected goal value entry"));
GoalsMenu->Append(MENU_ModifyGoalItem, wxT("M&odify Goal Value"), wxT("Attempts to change the selected goal value entry"));
MainMenu->Append(GoalsMenu, wxT("&Goals"));
wxMenu *ProximityMenu = new wxMenu();
ProximityMenu->Append(MENU_NewProximity, wxT("&New Proximity"), wxT("Creates a new proximity entry"));
ProximityMenu->Append(MENU_DeleteProximity, wxT("&Delete Proximity"), wxT("Deletes the selected proximity entry"));
ProximityMenu->AppendSeparator();
ProximityMenu->Append(MENU_SaveProximity, wxT("&Save Proximity"), wxT("Saves the opened proximity entry"));
MainMenu->Append(ProximityMenu, wxT("&Proximity"));
wxMenu *AboutMenu = new wxMenu();
AboutMenu->Append(MENU_About, wxT("A&bout"), wxT("Program Information"));
MainMenu->Append(AboutMenu, wxT("A&bout"));
SetMenuBar(MainMenu);
mErrorLog->Log(eqEmuLogBoth, "Creating Sizer.");
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
mErrorLog->Log(eqEmuLogBoth, "Creating Item List Box.");
ItemSelectionList = new wxListBox(this, LIST_Click, wxDefaultPosition, wxSize( -1,-1 ), 0, NULL, 0);
mErrorLog->Log(eqEmuLogBoth, "Adding Item List Box to Sizer.");
BoxSizer1->Add(ItemSelectionList, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5);
mErrorLog->Log(eqEmuLogBoth, "Creating Notebook Backing.");
MainNotebookBack = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0);
mErrorLog->Log(eqEmuLogBoth, "Creating Panels.");
MainPanel1 = new wxPanel(MainNotebookBack, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
MainPanel2 = new wxPanel(MainNotebookBack, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
MainPanel3 = new wxPanel(MainNotebookBack, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
MainPanel4 = new wxPanel(MainNotebookBack, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
MainPanel5 = new wxPanel(MainNotebookBack, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
mErrorLog->Log(eqEmuLogBoth, "Adding Panels to Notebook Backing.");
MainNotebookBack->AddPage(MainPanel1, wxT("General"), true);
MainNotebookBack->AddPage(MainPanel2, wxT("Activities"), false);
MainNotebookBack->AddPage(MainPanel3, wxT("Goals"), false);
MainNotebookBack->AddPage(MainPanel4, wxT("Proximities"), false);
MainNotebookBack->AddPage(MainPanel5, wxT("Task Sets"), false);
/*General Page Elements*/
mErrorLog->Log(eqEmuLogBoth, "Adding elements to General Page");
//name label + text
mTaskNameLabel = new wxStaticText(MainPanel1, -1, "Name:", wxPoint(0,2), wxDefaultSize);
mTaskName = new wxTextCtrl(MainPanel1, -1, wxT("Task Name"), wxPoint(65,0), wxSize(300,20));
mTaskName->SetMaxLength(100);
mTaskName->Disable();
//desc label + text
mTaskDescLabel = new wxStaticText(MainPanel1, -1, "Desc:", wxPoint(0,32), wxDefaultSize);
mTaskDesc = new wxTextCtrl(MainPanel1, -1, wxT("Task Description"), wxPoint(65,30), wxSize(300,200), wxTE_MULTILINE);
mTaskDesc->SetMaxLength(2047);
mTaskDesc->Disable();
//Min Level label + text
mTaskMinLvlLabel = new wxStaticText(MainPanel1, -1, "Min Lvl:", wxPoint(375,2), wxDefaultSize);
mTaskMinLvl = new wxTextCtrl(MainPanel1, -1, wxT("0"), wxPoint(450,0), wxSize(25,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mTaskMinLvl->SetMaxLength(2);
mTaskMinLvl->Disable();
//Max Level label + text
mTaskMaxLvlLabel = new wxStaticText(MainPanel1, -1, "Max Lvl:", wxPoint(500,2), wxDefaultSize);
mTaskMaxLvl = new wxTextCtrl(MainPanel1, -1, wxT("0"), wxPoint(580,0), wxSize(25,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mTaskMaxLvl->SetMaxLength(2);
mTaskMaxLvl->Disable();
//duration
mTaskDurationLabel = new wxStaticText(MainPanel1, -1, "Duration:", wxPoint(375,32), wxDefaultSize);
mTaskDuration = new wxTextCtrl(MainPanel1, -1, wxT("0"), wxPoint(450,30), wxSize(70,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mTaskDuration->SetMaxLength(9);
mTaskDuration->Disable();
//box to enclose rewards
mRewardsBox = new wxStaticBox(MainPanel1, -1, "Rewards", wxPoint(0,300), wxSize(644,210));
mRewardNameLabel = new wxStaticText(mRewardsBox, -1, "Reward:", wxPoint(10,17), wxDefaultSize);
mRewardName = new wxTextCtrl(mRewardsBox, -1, wxT(""), wxPoint(80,15), wxSize(280,20));
mRewardName->SetMaxLength(64);
mRewardName->Disable();
mRewardIDLabel = new wxStaticText(mRewardsBox, -1, "Reward ID:", wxPoint(10,47), wxDefaultSize);
mRewardID = new wxTextCtrl(mRewardsBox, -1, wxT("0"), wxPoint(160,45), wxSize(70,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mRewardID->SetMaxLength(9);
mRewardID->Disable();
mRewardCashLabel = new wxStaticText(mRewardsBox, -1, "Money Rewarded:", wxPoint(10,77), wxDefaultSize);
mRewardCash = new wxTextCtrl(mRewardsBox, -1, wxT("0"), wxPoint(160,75), wxSize(70,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mRewardCash->SetMaxLength(9);
mRewardCash->Disable();
mRewardXPLabel = new wxStaticText(mRewardsBox, -1, "Experience Rewarded:", wxPoint(10,107), wxDefaultSize);
mRewardXP = new wxTextCtrl(mRewardsBox, -1, wxT("0"), wxPoint(160,105), wxSize(70,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mRewardXP->SetMaxLength(9);
mRewardXP->Disable();
mRewardMethodLabel = new wxStaticText(mRewardsBox, -1, "Reward Method:", wxPoint(10,137), wxDefaultSize);
mRewardMethod = new wxChoice(mRewardsBox, -1, wxPoint(160, 135), wxDefaultSize);
wxString mRewardMethodStr;
mRewardMethodStr.Printf("%s", "(0) Single Item Id");
mRewardMethod->Append(mRewardMethodStr);
mRewardMethodStr.clear();
mRewardMethodStr.Printf("%s", "(1) List from Goal List");
mRewardMethod->Append(mRewardMethodStr);
mRewardMethodStr.clear();
mRewardMethodStr.Printf("%s", "(2) Perl Quest Reward");
mRewardMethod->Append(mRewardMethodStr);
mRewardMethod->Select(0);
mRewardMethod->Disable();
ShowRewardItems = new wxListBox(mRewardsBox, -1, wxPoint(375, 40), wxSize(250,160), 0, NULL, 0);
ShowRewardItems->Disable();
RefreshItems = new wxButton(mRewardsBox,BUTTON_Reward,"Refresh Item List", wxPoint(375,10), wxSize(250,25));
RefreshItems->Disable();
mStartZoneLabel = new wxStaticText(MainPanel1, -1, "Start Zone:", wxPoint(375,62), wxDefaultSize);
mStartZone = new wxChoice(MainPanel1, -1, wxPoint(460, 60), wxDefaultSize, 0, NULL, wxCB_SORT);
mStartZone->Disable();
mTaskRepeatable = new wxCheckBox(MainPanel1, -1, "Repeatable:", wxPoint(375, 87), wxDefaultSize, wxCHK_2STATE | wxALIGN_RIGHT);
mTaskRepeatable->Disable();
/*General Page Elements End*/
/*Activities Page Elements*/
mErrorLog->Log(eqEmuLogBoth, "Adding elements to Activities Page");
ActivitiesSelectionList = new wxListBox(MainPanel2, LIST_Click_Activities, wxPoint(0,0), wxSize(100,510), 0, NULL, 0);
ActivitiesSelectionList->Disable();
mActText1Label = new wxStaticText(MainPanel2, -1, "Text 1:", wxPoint(105,2), wxDefaultSize);
mActText1 = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(185,0), wxSize(180,20), wxTE_DONTWRAP);
mActText1->SetMaxLength(64);
mActText1->Disable();
mActText2Label = new wxStaticText(MainPanel2, -1, "Text 2:", wxPoint(105,22), wxDefaultSize);
mActText2 = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(185,20), wxSize(180,20), wxTE_DONTWRAP);
mActText2->SetMaxLength(64);
mActText2->Disable();
mActText3Label = new wxStaticText(MainPanel2, -1, "Text 3:", wxPoint(105,42), wxDefaultSize);
mActText3 = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(185,40), wxSize(180,60), wxTE_MULTILINE);
mActText3->SetMaxLength(128);
mActText3->Disable();
mActivityZoneLabel = new wxStaticText(MainPanel2, -1, "Zone:", wxPoint(380,2), wxDefaultSize);
mActivityZone = new wxChoice(MainPanel2, -1, wxPoint(440, 0), wxDefaultSize, 0, NULL, wxCB_SORT);
mActivityZone->Disable();
mActivityOptional = new wxCheckBox(MainPanel2, -1, "Optional:", wxPoint(580, 2), wxDefaultSize, wxCHK_2STATE | wxALIGN_RIGHT);
mActivityOptional->Disable();
mActIDLabel = new wxStaticText(MainPanel2, -1, "Activity ID:", wxPoint(105,107), wxDefaultSize);
mActID = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(185,105), wxSize(25,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mActID->SetMaxLength(2);
mActID->Disable();
mActStepLabel = new wxStaticText(MainPanel2, -1, "Step:", wxPoint(105,129), wxDefaultSize);
mActStep = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(185,127), wxSize(25,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mActStep->SetMaxLength(2);
mActStep->Disable();
mActTypeLabel = new wxStaticText(MainPanel2, -1, "Type:", wxPoint(105,155), wxDefaultSize);
mActType = new wxChoice(MainPanel2, CHOICE_ActivityChoiceChange, wxPoint(185, 153), wxDefaultSize);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(0) Unknown");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(1) Deliver");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(2) Kill");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(3) Loot");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(4) Speak To");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(5) Explore");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(6) Trade Skill");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(7) Fish");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(8) Forage");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(9) Use");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(10) Use");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(11) Touch");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(100) GiveCash");
mActType->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(999) Custom");
mActType->Append(mRewardMethodStr);
mActType->Disable();
mActType->Select(0);
mActInfo = new wxStaticBox(MainPanel2, -1, "Info", wxPoint(425,385), wxSize(219,125));
mActInfoText = new wxStaticText(mActInfo, -1, "Unknown Activity Type:\nThis is not a valid activity type", wxPoint(25,25), wxDefaultSize);
mActDeliverLabel = new wxStaticText(MainPanel2, -1, "Deliver to NPCID:", wxPoint(105,182), wxDefaultSize);
mActDeliver = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(215,180), wxSize(60,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mActDeliver->SetMaxLength(7);
mActDeliver->Disable();
mActMethodLabel = new wxStaticText(MainPanel2, -1, "Goal Method:", wxPoint(105,402), wxDefaultSize);
mActMethod = new wxChoice(MainPanel2, -1, wxPoint(200, 400), wxDefaultSize);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(0) Single Goal ID");
mActMethod->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(1) Goal ID List");
mActMethod->Append(mRewardMethodStr);
mRewardMethodStr.Clear();
mRewardMethodStr.Printf("%s", "(2) Perl Quest");
mActMethod->Append(mRewardMethodStr);
mActMethod->Select(2);
mActMethod->Disable();
mActGoalIDLabel = new wxStaticText(MainPanel2, -1, "Goal ID:", wxPoint(105,432), wxDefaultSize);
mActGoalID = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(200,430), wxSize(60,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mActGoalID->SetMaxLength(7);
mActGoalID->Disable();
mActGoalCountLabel = new wxStaticText(MainPanel2, -1, "Goal Count:", wxPoint(105,457), wxDefaultSize);
mActGoalCount = new wxTextCtrl(MainPanel2, -1, wxT(""), wxPoint(200,455), wxSize(60,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mActGoalCount->SetMaxLength(8);
mActGoalCount->Disable();
/*Activities Page Elements End*/
/*Goals Page Elements*/
mErrorLog->Log(eqEmuLogBoth, "Adding elements to Goals Page");
GoalsSelectionList = new wxListBox(MainPanel3, LIST_Click_Goals, wxPoint(0,0), wxSize(100,510), 0, NULL, 0);
GoalsValuesList = new wxListBox(MainPanel3, -1, wxPoint(150,50), wxSize(150,300), 0, NULL, 0);
GoalsValuesList->Disable();
mGoalsNewValueButton = new wxButton(MainPanel3, BUTTON_AddGoalItem, "Add Value", wxPoint(302,275), wxSize(100,-1));
mGoalsNewValueButton->Disable();
mGoalsDeleteValueButton = new wxButton(MainPanel3, BUTTON_DeleteGoalItem, "Delete Value", wxPoint(302,300), wxSize(100,-1));
mGoalsDeleteValueButton->Disable();
mGoalsChangeValueButton = new wxButton(MainPanel3, BUTTON_ModifyGoalItem, "Change Value", wxPoint(302,325), wxSize(100,-1));
mGoalsChangeValueButton->Disable();
/*Goals Page Elements End*/
/*Proximities Page Elements*/
mErrorLog->Log(eqEmuLogBoth, "Adding elements to Proximities Page");
ProximitySelectionList = new wxListBox(MainPanel4, LIST_Click_Proximity, wxPoint(0,0), wxSize(100,510), 0, NULL, 0);
mProxIdLabel = new wxStaticText(MainPanel4, -1, "Id:", wxPoint(105,12), wxDefaultSize);
mProxId = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(150,10), wxSize(50,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxId->SetMaxLength(6);
mProxId->Disable();
mProxMinxLabel = new wxStaticText(MainPanel4, -1, "MinX:", wxPoint(105,42), wxDefaultSize);
mProxMinx = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(150,40), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMinx->SetMaxLength(12);
mProxMinx->Disable();
mProxMaxxLabel = new wxStaticText(MainPanel4, -1, "MaxX:", wxPoint(255,42), wxDefaultSize);
mProxMaxx = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(300,40), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMaxx->SetMaxLength(12);
mProxMaxx->Disable();
mProxMinyLabel = new wxStaticText(MainPanel4, -1, "MinY:", wxPoint(105,72), wxDefaultSize);
mProxMiny = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(150,70), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMiny->SetMaxLength(12);
mProxMiny->Disable();
mProxMaxyLabel = new wxStaticText(MainPanel4, -1, "MaxY:", wxPoint(255,72), wxDefaultSize);
mProxMaxy = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(300,70), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMaxy->SetMaxLength(12);
mProxMaxy->Disable();
mProxMinzLabel = new wxStaticText(MainPanel4, -1, "MinZ:", wxPoint(105,102), wxDefaultSize);
mProxMinz = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(150,100), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMinz->SetMaxLength(12);
mProxMinz->Disable();
mProxMaxzLabel = new wxStaticText(MainPanel4, -1, "MaxZ:", wxPoint(255,102), wxDefaultSize);
mProxMaxz = new wxTextCtrl(MainPanel4, -1, wxT(""), wxPoint(300,100), wxSize(80,20), wxTE_DONTWRAP, wxTextValidator(wxFILTER_NUMERIC));
mProxMaxz->SetMaxLength(12);
mProxMaxz->Disable();
mProxZoneLabel = new wxStaticText(MainPanel4, -1, "Zone:", wxPoint(105,202), wxDefaultSize);
mProxZone = new wxChoice(MainPanel4, -1, wxPoint(150, 200), wxDefaultSize);
mProxZone->Disable();
/*Proximities Page Elements End*/
mErrorLog->Log(eqEmuLogBoth, "Adding Notebook to Sizer.");
BoxSizer1->Add(MainNotebookBack, 1, wxALIGN_TOP|wxEXPAND, 5);
mErrorLog->Log(eqEmuLogBoth, "Setting Frame Sizer.");
this->SetSizer(BoxSizer1);
mErrorLog->Log(eqEmuLogBoth, "Calculating Frame Layout.");
this->Layout();
selectedIndex = -1; //nothing selected
openedIndex = -1; //nothing opened
highestIndex = 0;
openedActivity.activityid = -1;
openedActivity.id = -1;
openedActivity.step = -1;
openedGoal = 0;
openedProximity.exploreid = 0xFFFFFFFF;
openedProximity.zoneid = 0xFFFFFFFF;
//database setting init.
mMysql = NULL;
memset(server,0,256);
memset(user,0,256);
memset(password,0,256);
memset(database,0,256);
if(!GetDatabaseSettings())
Close(TRUE);
}
void MainFrame::Connect(wxCommandEvent& WXUNUSED(event))
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Connect to database requested but database connection exists.");
return;
}
ItemSelectionList->Clear();
mErrorLog->Log(eqEmuLogBoth, "Connect to database requested.");
if(!mMysql){
mMysql = mysql_init(NULL);
}
if(mMysql){
if (!mysql_real_connect(mMysql, server,
user, password, database, 0, NULL, 0)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
Close(TRUE);
return;
}
if(!LoadTasks()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load tasks, exiting.");
Close(TRUE);
return;
}
if(!LoadGoals()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load goals, exiting.");
Close(TRUE);
return;
}
if(!LoadActivities()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load activities, exiting.");
Close(TRUE);
return;
}
if(!LoadItems()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load items, exiting.");
Close(TRUE);
return;
}
if(!LoadZones()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load zones, exiting.");
Close(TRUE);
return;
}
if(!LoadProximity()){
mysql_close(mMysql);
mErrorLog->Log(eqEmuLogBoth, "Failed to load proximities, exiting.");
Close(TRUE);
return;
}
PopulateGoals();
PopulateProximity();
}
}
void MainFrame::Quit(wxCommandEvent& WXUNUSED(event))
{
mErrorLog->Log(eqEmuLogBoth, "Exit requested, exiting.");
delete mErrorLog;
mErrorLog = NULL;
mysql_close(mMysql);
Close(TRUE);
}
void MainFrame::ListBoxSimpleSelect(wxCommandEvent& event)
{
selectedIndex = event.GetInt();
}
void MainFrame::ListBoxDoubleClick(wxCommandEvent& event)
{
mErrorLog->Log(eqEmuLogBoth, "Double clicked on item %d.", event.GetInt());
openedIndex = event.GetInt();
vector<eqtask>::iterator Iter;
Iter = taskList.begin();
Iter += openedIndex;
eqtask mTask = *Iter;
wxString mStr;
mStr.Printf("%s", mTask.title);
mTaskName->Clear();
mTaskName->AppendText(mStr);
mTaskName->Enable();
mStr.clear();
mStr.Printf("%s", mTask.desc);
mTaskDesc->Clear();
mTaskDesc->AppendText(mStr);
mTaskDesc->Enable();
mStr.clear();
mStr.Printf("%u", mTask.level_min);
mTaskMinLvl->Clear();
mTaskMinLvl->AppendText(mStr);
mTaskMinLvl->Enable();
mStr.clear();
mStr.Printf("%u", mTask.level_max);
mTaskMaxLvl->Clear();
mTaskMaxLvl->AppendText(mStr);
mTaskMaxLvl->Enable();
mStr.clear();
mStr.Printf("%u", mTask.duration);
mTaskDuration->Clear();
mTaskDuration->AppendText(mStr);
mTaskDuration->Enable();
mStr.clear();
mStr.Printf("%s", mTask.reward);
mRewardName->Clear();
mRewardName->AppendText(mStr);
mRewardName->Enable();
mStr.clear();
mStr.Printf("%u", mTask.rewardid);
mRewardID->Clear();
mRewardID->AppendText(mStr);
mRewardID->Enable();
mStr.clear();
mStr.Printf("%u", mTask.cashreward);
mRewardCash->Clear();
mRewardCash->AppendText(mStr);
mRewardCash->Enable();
mStr.clear();
mStr.Printf("%i", mTask.xpreward);
mRewardXP->Clear();
mRewardXP->AppendText(mStr);
mRewardXP->Enable();
mStr.clear();
mRewardMethod->Select(mTask.rewardmethod);
mRewardMethod->Enable();
ShowRewardChange(mTask.rewardmethod, mTask.rewardid);
mStartZone->Enable();
SetZoneSelectionById(mTask.startzone);
mTaskRepeatable->Enable();
mTaskRepeatable->SetValue(mTask.repeatable);
ClearActivities();
ActivitiesSelectionList->Enable();
PopulateActivities();
openedActivity.activityid = -1;
openedActivity.id = -1;
openedActivity.step = -1;
mActText1->Clear();
mActText1->Disable();
mActText2->Clear();
mActText2->Disable();
mActText3->Clear();
mActText3->Disable();
mActivityZone->Select(0);
mActivityZone->Disable();
mActivityOptional->SetValue(false);
mActivityOptional->Disable();
mActID->Clear();
mActID->Disable();
mActStep->Clear();
mActStep->Disable();
mActType->Select(0);
mActType->Disable();
mActDeliver->Clear();
mActDeliver->Disable();
mActGoalID->Clear();
mActGoalID->Disable();
mActGoalCount->Clear();
mActGoalCount->Disable();
mActMethod->Select(2);
mActMethod->Disable();
ShowRewardItems->Enable();
RefreshItems->Enable();
}
void MainFrame::ContextClick(wxContextMenuEvent& event)
{
mErrorLog->Log(eqEmuLogBoth, "Context Menu Requested");
if(event.GetPosition() == wxDefaultPosition)
{
mErrorLog->Log(eqEmuLogBoth, "Context Menu Triggered From Keyboard.");
}
else{
wxPoint p = event.GetPosition();
mErrorLog->Log(eqEmuLogBoth, "Context Menu Triggered At (%d,%d)", p.x, p.y);
wxPoint stcp = ScreenToClient(p);
mErrorLog->Log(eqEmuLogBoth, "Context Menu Triggered At (%d,%d)(Adjusted for Client)", stcp.x, stcp.y);
//big box on the side: holds tasks
if(stcp.x >= 7 && stcp.x <= 133)
{
if(stcp.y >=7 && stcp.y <= 258)
{
ContextMenuTaskList();
}
}
//small box on the 2nd tab: must be on top to work
if(stcp.x >= 146 && stcp.x <= 243)
{
if(stcp.y >=23 && stcp.y <= 529)
{
if(MainPanel2->IsShownOnScreen())
ContextMenuActivityList();
else if(MainPanel3->IsShownOnScreen())
ContextMenuGoalList();
else if(MainPanel4->IsShownOnScreen())
ContextMenuProximity();
}
}
if(stcp.x >= 297 && stcp.x <= 442)
{
if(stcp.y >= 74 && stcp.y <= 368)
{
if(MainPanel3->IsShownOnScreen() && GoalsValuesList->IsEnabled())
ContextMenuGoalValueList();
}
}
}
}
void MainFrame::About(wxCommandEvent& event)
{
wxAboutDialogInfo info;
info.SetName(_("Task Master"));
info.SetVersion(_(TASK_MASTER_VERSION));
info.SetDescription(_("Task Creation Tool"));
info.SetWebSite("www.eqemulator.net");
wxAboutBox(info);
}
+255
View File
@@ -0,0 +1,255 @@
#ifndef EQWX_BASE__H
#define EQWX_BASE__H
#include <wx/frame.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <mysql.h>
#include "ErrorLog.h"
#include "tasks.h"
#include "items.h"
#include <vector>
#define TASK_MASTER_VERSION "1.0.8"
class MainApp: public wxApp
{
public:
virtual bool OnInit();
};
class MainFrame: public wxFrame
{
public:
MainFrame( const wxString& title, const wxPoint& pos, const wxSize& size );
wxTextCtrl *MainEditBox;
wxMenuBar *MainMenu;
//various elements
wxBoxSizer* BoxSizer1;
wxListBox *ItemSelectionList;
wxNotebook *MainNotebookBack;
wxPanel *MainPanel1;
/*General Panel Controls*/
wxStaticText *mTaskNameLabel;
wxTextCtrl *mTaskName;
wxStaticText *mTaskDescLabel;
wxTextCtrl *mTaskDesc;
wxStaticText *mTaskMinLvlLabel;
wxTextCtrl *mTaskMinLvl;
wxStaticText *mTaskMaxLvlLabel;
wxTextCtrl *mTaskMaxLvl;
wxStaticText *mTaskDurationLabel;
wxTextCtrl *mTaskDuration;
wxStaticBox *mRewardsBox;
wxStaticText *mRewardNameLabel;
wxTextCtrl *mRewardName;
wxStaticText *mRewardIDLabel;
wxTextCtrl *mRewardID;
wxStaticText *mRewardCashLabel;
wxTextCtrl *mRewardCash;
wxStaticText *mRewardXPLabel;
wxTextCtrl *mRewardXP;
wxStaticText *mRewardMethodLabel;
wxChoice *mRewardMethod;
wxListBox *ShowRewardItems;
wxButton *RefreshItems;
wxStaticText *mStartZoneLabel;
wxChoice *mStartZone;
wxCheckBox *mTaskRepeatable;
/*General Panel Controls End*/
wxPanel *MainPanel2;
/*Activities Panel Controls*/
wxListBox *ActivitiesSelectionList;
wxStaticText *mActText1Label;
wxTextCtrl *mActText1;
wxStaticText *mActText2Label;
wxTextCtrl *mActText2;
wxStaticText *mActText3Label;
wxTextCtrl *mActText3;
wxStaticText *mActivityZoneLabel;
wxChoice *mActivityZone;
wxCheckBox *mActivityOptional;
wxStaticText *mActIDLabel;
wxTextCtrl *mActID;
wxStaticText *mActStepLabel;
wxTextCtrl *mActStep;
wxStaticText *mActTypeLabel;
wxChoice *mActType;
wxStaticBox *mActInfo;
wxStaticText *mActInfoText;
wxStaticText *mActDeliverLabel;
wxTextCtrl *mActDeliver;
wxStaticText *mActMethodLabel;
wxChoice *mActMethod;
wxStaticText *mActGoalIDLabel;
wxTextCtrl *mActGoalID;
wxStaticText *mActGoalCountLabel;
wxTextCtrl *mActGoalCount;
/*Activities Panel Controls End*/
wxPanel *MainPanel3;
/*Goals Panel Control Start*/
wxListBox *GoalsSelectionList;
wxListBox *GoalsValuesList;
wxButton *mGoalsNewValueButton;
wxButton *mGoalsDeleteValueButton;
wxButton *mGoalsChangeValueButton;
/*Goals Panel Control End*/
wxPanel *MainPanel4;
/*Proximity Panel Control Start*/
wxListBox *ProximitySelectionList;
wxStaticText *mProxIdLabel;
wxTextCtrl *mProxId;
wxStaticText *mProxMinxLabel;
wxTextCtrl *mProxMinx;
wxStaticText *mProxMaxxLabel;
wxTextCtrl *mProxMaxx;
wxStaticText *mProxMinyLabel;
wxTextCtrl *mProxMiny;
wxStaticText *mProxMaxyLabel;
wxTextCtrl *mProxMaxy;
wxStaticText *mProxMinzLabel;
wxTextCtrl *mProxMinz;
wxStaticText *mProxMaxzLabel;
wxTextCtrl *mProxMaxz;
wxStaticText *mProxZoneLabel;
wxChoice *mProxZone;
/*Proximity Panel Control End*/
wxPanel *MainPanel5;
/*Task Set Panel Control Start*/
/*Task Set Panel Control End*/
//error
EQEmuErrorLog *mErrorLog;
/*database stuff*/
MYSQL *mMysql;
char server[256];
char user[256];
char password[256];
char database[256];
bool GetDatabaseSettings();
bool LoadTasks();
bool LoadGoals();
bool LoadActivities();
bool LoadItems();
bool LoadZones();
bool LoadProximity();
//I use vectors for everything speed of adding/removing isn't an issue for me.
//Could use list for task, goals and activities if wanted.
std::vector<eqtask> taskList;
std::vector<eqtask_goallist> goalTaskList;
std::vector<eqitem> itemList;
std::vector<eqtask_activities> taskActivitiesList;
std::vector<eqtask_zones> taskZoneList;
std::vector<eqtask_proximity> taskProximityList;
int selectedIndex;
int openedIndex;
unsigned int highestIndex;
eqtask_activity_id openedActivity;
int openedGoal;
eqtask_prox openedProximity;
void Connect(wxCommandEvent& event);
void Save(wxCommandEvent& event);
void Quit(wxCommandEvent& event);
void NewTask(wxCommandEvent& event);
void DeleteTask(wxCommandEvent& event);
void SaveTask(wxCommandEvent& event);
void About(wxCommandEvent& event);
void NewActivity(wxCommandEvent& event);
void DeleteActivity(wxCommandEvent& event);
void SaveActivity(wxCommandEvent& event);
void ListBoxDoubleClick(wxCommandEvent& event);
void ListBoxSimpleSelect(wxCommandEvent& event);
void OnRewardButton(wxCommandEvent& event);
void ActivitiesListBoxSimpleSelect(wxCommandEvent& event);
void ActivitiesListBoxDoubleClick(wxCommandEvent& event);
void ActivityChoiceChange(wxCommandEvent& event);
void PopulateActivities();
void FillActivity(int id, int activityid, int step);
void GoalsListBoxDoubleClick(wxCommandEvent& event);
void PopulateGoals();
void PopulateGoalValues(unsigned int goalid);
void ClearGoalValues();
void NewGoal(wxCommandEvent& event);
void DeleteGoal(wxCommandEvent& event);
void NewGoalValue(wxCommandEvent& event);
void DeleteGoalValue(wxCommandEvent& event);
void ChangeGoalValue(wxCommandEvent& event);
void ProximityListBoxDoubleClick(wxCommandEvent& event);
void NewProximity(wxCommandEvent& event);
void DeleteProximity(wxCommandEvent& event);
void SaveProximity(wxCommandEvent& event);
void PopulateProximity();
void FillProximityValues(unsigned int zone, unsigned int explore);
void ShowRewardChange(int rewardType, int rewardId);
void SetZoneSelectionById(int zid);
void SetZoneSelectionByIdActivity(int zid);
void SetZoneSelectionByIdProximity(int zid);
wxString MakeStringSQLSafe(const char * c);
void ContextClick(wxContextMenuEvent& event);
void ContextMenuTaskList();
void ContextMenuActivityList();
void ContextMenuGoalList();
void ContextMenuGoalValueList();
void ContextMenuProximity();
//we need to free the memory used when we change activites becase we attach it to
//the items in our activities table and don't have any other way to track them so
//Free it up before we call ActivitiesSelectionList->Clear();
void ClearActivities();
DECLARE_EVENT_TABLE()
};
enum
{
TEXT_Main = wxID_HIGHEST + 1,
MENU_Connect,
MENU_Quit,
MENU_NewTask,
MENU_DeleteTask,
MENU_SaveTask,
LIST_Click,
BUTTON_Reward,
LIST_Click_Activities,
MENU_NewActivity,
MENU_DeleteActivity,
MENU_SaveActivity,
CHOICE_ActivityChoiceChange,
MENU_About,
LIST_Click_Goals,
MENU_NewGoal,
MENU_DeleteGoal,
MENU_AddGoalItem,
MENU_DeleteGoalItem,
MENU_ModifyGoalItem,
BUTTON_AddGoalItem,
BUTTON_DeleteGoalItem,
BUTTON_ModifyGoalItem,
MENU_NewProximity,
MENU_DeleteProximity,
MENU_SaveProximity,
LIST_Click_Proximity,
};
#endif
+442
View File
@@ -0,0 +1,442 @@
#include <wx/wx.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "items.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
bool MainFrame::GetDatabaseSettings(){
FILE *mFile = NULL;
mFile = fopen("db.txt", "r");
//very little error checking
//we don't make sure the values in the file are valid
//or all there just that the file exists so:
//don't fuck this up.
if(mFile){
//this isn't all that safe
char chunk[256];
memset(chunk, 0, 256);
fgets(chunk, 256, mFile);
strcpy(server, chunk);
for(int i = 0; i<256; i++){
if(server[i] == '\n')
server[i] = '\0';
}
memset(chunk, 0, 256);
fgets(chunk, 256, mFile);
strcpy(database, chunk);
for(int i = 0; i<256; i++){
if(database[i] == '\n')
database[i] = '\0';
}
memset(chunk, 0, 256);
fgets(chunk, 256, mFile);
strcpy(user, chunk);
for(int i = 0; i<256; i++){
if(user[i] == '\n')
user[i] = '\0';
}
memset(chunk, 0, 256);
fgets(chunk, 256, mFile);
strcpy(password, chunk);
for(int i = 0; i<256; i++){
if(password[i] == '\n')
password[i] = '\0';
}
memset(chunk, 0, 256);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Error opening file db.txt, could not read db settings.");
return false;
}
return true;
}
bool MainFrame::LoadItems(){
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Items...");
unsigned int itemsLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT name,id FROM items")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqitem newIT;
strcpy(newIT.name, row[0]);
newIT.id = atoi(row[1]);
itemList.push_back(newIT);
itemsLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Items", itemsLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for item load.");
return false;
}
return true;
}
bool MainFrame::LoadZones()
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Zones...");
unsigned int zonesLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT short_name,zoneidnumber FROM zone")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
wxString zoneStr;
zoneStr.Printf("**Unknown Zone**");
int * id = new int;
*id = -1;
mStartZone->Append(zoneStr, (void*)id);
zoneStr.Clear();
zoneStr.Printf("*Any Zone*");
id = new int;
*id = 0;
mStartZone->Append(zoneStr, (void*)id);
mActivityZone->Append(zoneStr, (void*)id);
mProxZone->Append(zoneStr, (void*)id);
zoneStr.clear();
mStartZone->Select(0);
mActivityZone->Select(0);
mProxZone->Select(0);
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqtask_zones newZ;
strcpy(newZ.name, row[0]);
newZ.id = atoi(row[1]);
taskZoneList.push_back(newZ);
int * zoneId = new int;
*zoneId = newZ.id;
wxString zoneNameStr;
zoneNameStr.Printf("%s", newZ.name);
mStartZone->Append(zoneNameStr, (void*)zoneId);
mActivityZone->Append(zoneNameStr, (void*)zoneId);
mProxZone->Append(zoneNameStr, (void*)zoneId);
zoneNameStr.clear();
zonesLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Zones", zonesLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for zone load.");
return false;
}
return true;
}
bool MainFrame::LoadTasks()
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Tasks...");
unsigned int tasksLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT id, title, description, reward, rewardid, cashreward, xpreward, rewardmethod, startzone, duration, minlevel, maxlevel, repeatable FROM tasks")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqtask newT;
newT.id = atoi(row[0]);
//This isn't all that safe
//Working under the assumption that:
//Any database you connect to is not
//Going to want to hurt you
strcpy(newT.title, row[1]);
strcpy(newT.desc, row[2]);
strcpy(newT.reward, row[3]);
wxString str;
str.Printf("%d:%s", newT.id, newT.title);
ItemSelectionList->Append(str);
if(newT.id > highestIndex)
highestIndex = newT.id;
newT.rewardid = atoi(row[4]);
newT.cashreward = atoi(row[5]);
newT.xpreward = atoi(row[6]);
newT.rewardmethod = atoi(row[7]);
newT.startzone = atoi(row[8]);
newT.duration = atoi(row[9]);
newT.level_min = atoi(row[10]);
newT.level_max = atoi(row[11]);
newT.repeatable = atoi(row[12]) ? true : false;
taskList.push_back(newT);
tasksLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Tasks", tasksLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for task load.");
return false;
}
return true;
}
bool MainFrame::LoadGoals()
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Goals...");
unsigned int goalsLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT listid, entry FROM goallists")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqtask_goallist newGL;
newGL.id = atoi(row[0]);
newGL.value = atoi(row[1]);
goalTaskList.push_back(newGL);
goalsLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Goals", goalsLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for goal load.");
return false;
}
return true;
}
bool MainFrame::LoadActivities()
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Activities...");
unsigned int activitiesLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT taskid, activityid, step, activitytype, text1, text2, text3, goalid, goalmethod, goalcount, delivertonpc, zoneid, optional FROM activities")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqtask_activities newAL;
newAL.id = atoi(row[0]);
newAL.activityId = atoi(row[1]);
newAL.step = atoi(row[2]);
newAL.activityType = atoi(row[3]);
strcpy(newAL.text1, row[4]);
strcpy(newAL.text2, row[5]);
strcpy(newAL.text3, row[6]);
newAL.goalid = atoi(row[7]);
newAL.goalmethod = atoi(row[8]);
newAL.goalcount = atoi(row[9]);
newAL.deliverToNpc = atoi(row[10]);
newAL.zoneid = atoi(row[11]);
newAL.optional = atoi(row[12]) ? true : false;
taskActivitiesList.push_back(newAL);
activitiesLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Activities", activitiesLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for activity load.");
return false;
}
return true;
}
bool MainFrame::LoadProximity()
{
if(mMysql){
mErrorLog->Log(eqEmuLogBoth, "Loading Proximities...");
unsigned int proximitiesLoaded = 0;
MYSQL_RES *res;
MYSQL_ROW row;
if (mysql_query(mMysql, "SELECT zoneid, exploreid, minx, maxx, miny, maxy, minz, maxz FROM proximities")) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Connection Error: %s", mysql_error(mMysql));
return false;
}
res = mysql_use_result(mMysql);
while ((row = mysql_fetch_row(res)) != NULL){
eqtask_proximity newPR;
newPR.zoneid = atoi(row[0]);
newPR.exploreid = atoi(row[1]);
newPR.minx = atof(row[2]);
newPR.maxx = atof(row[3]);
newPR.miny = atof(row[4]);
newPR.maxy = atof(row[5]);
newPR.minz = atof(row[6]);
newPR.maxz = atof(row[7]);
taskProximityList.push_back(newPR);
proximitiesLoaded++;
}
mErrorLog->Log(eqEmuLogBoth, "%u Successfully Loaded Proximities", proximitiesLoaded);
mysql_free_result(res);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Mysql connection did not exist for proximity load.");
return false;
}
return true;
}
void MainFrame::ShowRewardChange(int rewardType, int rewardId)
{
if(rewardType == 2){
ShowRewardItems->Clear();
}
else if(rewardType == 0 && rewardId != 0){
ShowRewardItems->Clear();
vector<eqitem>::iterator Iter;
for(Iter = itemList.begin(); Iter!=itemList.end(); Iter++)
{
eqitem eqi = *Iter;
if(eqi.id == rewardId){
wxString itStr;
itStr.Printf("%u: %s", eqi.id, eqi.name);
ShowRewardItems->Append(itStr);
itStr.clear();
}
}
}
else if(rewardType == 1 && rewardId != 0)
{
ShowRewardItems->Clear();
vector<eqtask_goallist>::iterator Iter;
for(Iter = goalTaskList.begin(); Iter!=goalTaskList.end(); Iter++)
{
eqtask_goallist gli = *Iter;
if(gli.id == rewardId)
{
vector<eqitem>::iterator itemIter;
for(itemIter = itemList.begin(); itemIter!=itemList.end(); itemIter++)
{
eqitem eqi = *itemIter;
if(eqi.id == gli.value)
{
wxString itStr;
itStr.Printf("%u: %s", eqi.id, eqi.name);
ShowRewardItems->Append(itStr);
itStr.clear();
}
}
}
}
}
else{
ShowRewardItems->Clear();
}
}
void MainFrame::SetZoneSelectionById(int zid)
{
for(unsigned int x = 0; x < mStartZone->GetCount(); x++)
{
int *i;
i = (int*) mStartZone->GetClientData(x);
if(i){
if(*i == zid){
mStartZone->Select(x);
return;
}
}
else
{
mErrorLog->Log(eqEmuLogBoth, "MainFrame::SetZoneSelectionById: i was NULL");
}
}
mStartZone->Select(0); //we have no valid zone
}
void MainFrame::SetZoneSelectionByIdActivity(int zid)
{
for(unsigned int x = 0; x < mActivityZone->GetCount(); x++)
{
int *i;
i = (int*) mActivityZone->GetClientData(x);
if(i){
if(*i == zid){
mActivityZone->Select(x);
return;
}
}
else
{
mErrorLog->Log(eqEmuLogBoth, "MainFrame::SetZoneSelectionByIdActivity: i was NULL");
}
}
mActivityZone->Select(0); //we have no valid zone
}
void MainFrame::SetZoneSelectionByIdProximity(int zid)
{
for(unsigned int x = 0; x < mProxZone->GetCount(); x++)
{
int *i;
i = (int*) mProxZone->GetClientData(x);
if(i){
if(*i == zid){
mProxZone->Select(x);
return;
}
}
else
{
mErrorLog->Log(eqEmuLogBoth, "MainFrame::SetZoneSelectionByIdProximity: i was NULL");
}
}
mProxZone->Select(0); //we have no valid zone
}
wxString MainFrame::MakeStringSQLSafe(const char * c)
{
wxString ret;
ret.Printf("%s", c);
ret.Replace("\'", "\\\'");
return ret;
}
+21
View File
@@ -0,0 +1,21 @@
=01/09/2010=
Trevius: The xpreward field now allows a negative value to match a change in Rev1803.
=04/27/2009=
KLS: Fix for reward method not saving.
=10/12/2008=
KLS: Improved some sql syntax to be more safe.
KLS: Increased the size of goal count box significantly.
KLS: Added id select for new task.
KLS: Made change goal value more smooth.
KLS: Removed database.cpp and database.h from project file.
=10/11/2008=
KLS: SQL logging will now include a time stamped comment
KLS: Updated some SQL queries.
KLS: Changed default sql log file.
KLS: Added method to account for ' in SQL syntax. Can expand to other control characters if needed
=10/10/2008=
KLS: Initial Entry.
+433
View File
@@ -0,0 +1,433 @@
#include <wx/wx.h>
#include <wx/numdlg.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
void MainFrame::GoalsListBoxDoubleClick(wxCommandEvent& event)
{
int * i = (int*) GoalsSelectionList->GetClientData(event.GetInt());
if(i){
int mI = *i;
PopulateGoalValues(mI);
}
}
void MainFrame::PopulateGoals()
{
mErrorLog->Log(eqEmuLogBoth, "Adding goals to the goal list box");
vector<eqtask_goallist>::iterator Iter;
if(goalTaskList.size() == 0)
{
mErrorLog->Log(eqEmuLogBoth, "No goals in DB, cannot add to list box");
return;
}
for(Iter = goalTaskList.begin(); Iter != goalTaskList.end(); Iter++)
{
eqtask_goallist val = (*Iter);
bool exists = false;
if(GoalsSelectionList->GetCount() > 0){
for(unsigned int i = 0; i < GoalsSelectionList->GetCount(); i++)
{
int *cd = (int*)GoalsSelectionList->GetClientData(i);
if(*cd == val.id){
exists = true;
}
}
}
if(!exists){
int *newCD = new int;
*newCD = val.id;
wxString newStr;
newStr.Printf("%u", *newCD);
GoalsSelectionList->Append(newStr, (void*)newCD);
}
}
}
void MainFrame::PopulateGoalValues(unsigned int goalid)
{
GoalsValuesList->Enable();
mGoalsNewValueButton->Enable();
mGoalsDeleteValueButton->Enable();
mGoalsChangeValueButton->Enable();
ClearGoalValues();
openedGoal = goalid;
vector<eqtask_goallist>::iterator Iter;
if(goalTaskList.size() != 0){
for(Iter = goalTaskList.begin(); Iter != goalTaskList.end(); Iter++)
{
if((*Iter).id == goalid){
int *i = new int;
*i = (*Iter).value;
wxString curStr;
curStr.Clear();
curStr.Printf("%u", (*Iter).value);
GoalsValuesList->Append(curStr, (void*)i);
}
}
}
}
void MainFrame::ClearGoalValues()
{
if(GoalsValuesList->GetCount() > 0){
for(unsigned int x = 0; x < GoalsValuesList->GetCount(); x++)
{
int *i = (int*)GoalsValuesList->GetClientData(x);
if(i){
delete i;
i = 0;
}
}
}
GoalsValuesList->Clear();
}
void MainFrame::NewGoal(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "New goal failed, not connected to db");
return;
}
int newID = wxGetNumberFromUser("", "New ID:", "Input ID", 0, 0, 9999999);
int newVal = wxGetNumberFromUser("", "New Value:", "Input Value", 0, 0, 9999999);
bool exists = false;
for(unsigned int x = 0; x < GoalsSelectionList->GetCount(); x++)
{
int *di = (int*)GoalsSelectionList->GetClientData(x);
if(*di == newID)
exists = true;
}
if(exists){
mErrorLog->Log(eqEmuLogBoth, "New goal failed, already exists");
return;
}
if(newID <= 0){
mErrorLog->Log(eqEmuLogBoth, "New goal failed, ID <= 0");
return;
}
if(newVal < 0){
mErrorLog->Log(eqEmuLogBoth, "New goal failed, Val < 0");
return;
}
char * mQuery = 0;
MakeAnyLenString(&mQuery, "INSERT INTO `goallists` (`listid`,`entry`) VALUES (%u,%u)", newID, newVal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
eqtask_goallist newGoal;
newGoal.id = newID;
newGoal.value = newVal;
goalTaskList.push_back(newGoal);
wxString newGoalStr;
newGoalStr.Printf("%u", newGoal.id);
int * i = new int;
*i = newGoal.id;
GoalsSelectionList->Append(newGoalStr, (void*)i);
}
void MainFrame::DeleteGoal(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Delete goal failed, not connected to db");
return;
}
if(GoalsSelectionList->GetCount() == 0)
{
mErrorLog->Log(eqEmuLogBoth, "Delete goal failed, does not exist");
return;
}
if(GoalsSelectionList->GetSelection() == wxNOT_FOUND)
{
mErrorLog->Log(eqEmuLogBoth, "Delete goal failed, nothing selected");
return;
}
int *mId;
mId = (int*)GoalsSelectionList->GetClientData(GoalsSelectionList->GetSelection());
if(!mId){
mErrorLog->Log(eqEmuLogBoth, "Delete goal failed, mId is NULL");
return;
}
int reply = wxMessageBox("Are you sure?", "Confirm Delete", wxYES_NO, this);
if(reply != wxYES)
{
mErrorLog->Log(eqEmuLogBoth, "User aborted delete of goal");
return;
}
int delVal = *mId;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM goallists where listid=%u", delVal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
vector<eqtask_goallist>::iterator Iter;
for(Iter = goalTaskList.begin(); Iter != goalTaskList.end(); Iter++)
{
if((*Iter).id == delVal)
{
goalTaskList.erase(Iter);
Iter = goalTaskList.begin();
}
}
if(delVal == openedGoal){
ClearGoalValues();
openedGoal = 0;
mGoalsNewValueButton->Disable();
mGoalsDeleteValueButton->Disable();
mGoalsChangeValueButton->Disable();
}
for(unsigned int x = 0; x < GoalsSelectionList->GetCount(); x++)
{
int * ni = (int*)GoalsSelectionList->GetClientData(x);
if(ni){
if(*ni == delVal){
delete ni;
ni = NULL;
GoalsSelectionList->Delete(x);
return;
}
}
}
}
void MainFrame::NewGoalValue(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "New goal value failed, not connected to db");
return;
}
if(!GoalsValuesList->IsEnabled())
{
mErrorLog->Log(eqEmuLogBoth, "New goal value failed, goal values not active");
return;
}
int newVal = wxGetNumberFromUser("", "Value:", "Input Value", 0, 0, 9999999);
if(newVal < 0){
mErrorLog->Log(eqEmuLogBoth, "New goal value failed, Val < 0");
}
int id = openedGoal;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "INSERT INTO `goallists` (`listid`,`entry`) VALUES (%u,%u)", id, newVal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
int * iptr = new int;
*iptr = newVal;
wxString iStr;
iStr.Printf("%u", newVal);
GoalsValuesList->Append(iStr, (void*)iptr);
eqtask_goallist newGoal;
newGoal.id = id;
newGoal.value = newVal;
goalTaskList.push_back(newGoal);
}
void MainFrame::DeleteGoalValue(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Delete goal value failed, not connected to db");
return;
}
if(!GoalsValuesList->IsEnabled()){
mErrorLog->Log(eqEmuLogBoth, "Delete goal value failed, goal values not active");
return;
}
if(GoalsValuesList->GetCount() <= 1)
{
mErrorLog->Log(eqEmuLogBoth, "Delete goal value failed, too few values");
return;
}
int ourId = openedGoal;
int ourVal;
int *iPtr = (int*)GoalsValuesList->GetClientData(GoalsValuesList->GetSelection());
if(!iPtr){
mErrorLog->Log(eqEmuLogBoth, "Delete goal value failed, iPtr is NULL");
return;
}
int reply = wxMessageBox("Are you sure?", "Confirm Delete", wxYES_NO, this);
if(reply != wxYES)
{
mErrorLog->Log(eqEmuLogBoth, "User aborted delete of goal value");
return;
}
ourVal = *iPtr;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM goallists WHERE listid=%u AND entry=%u", ourId, ourVal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
for(unsigned int x = 0; x < GoalsValuesList->GetCount(); x++)
{
int *ip = (int*)GoalsValuesList->GetClientData(x);
if(ip){
if(*ip == ourVal){
GoalsValuesList->Delete(x);
break;
}
}
}
vector<eqtask_goallist>::iterator Iter;
for(Iter = goalTaskList.begin(); Iter != goalTaskList.end(); Iter++)
{
if((*Iter).value == ourVal && (*Iter).id == ourId)
{
goalTaskList.erase(Iter);
return;
}
}
}
void MainFrame::ChangeGoalValue(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Modify goal value failed, not connected to db");
return;
}
if(!GoalsValuesList->IsEnabled()){
mErrorLog->Log(eqEmuLogBoth, "Modify goal value failed, goal values not active");
return;
}
if(GoalsValuesList->GetSelection() == wxNOT_FOUND)
{
mErrorLog->Log(eqEmuLogBoth, "Modify goal value failed, no selection found");
return;
}
int changedId = openedGoal;
int changedGoal;
int * changedGoalPtr = (int*)GoalsValuesList->GetClientData(GoalsValuesList->GetSelection());
if(!changedGoalPtr)
{
mErrorLog->Log(eqEmuLogBoth, "Modify goal value failed, changedGoalPtr was NULL");
return;
}
changedGoal = *changedGoalPtr;
int newVal = wxGetNumberFromUser("", "Value:", "Input Value", changedGoal, 0, 9999999);
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM goallists WHERE listid=%u AND entry=%u", changedId, changedGoal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
MakeAnyLenString(&mQuery, "INSERT INTO `goallists` (`listid`,`entry`) VALUES (%u,%u)", changedId, newVal);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
for(unsigned int x = 0; x < GoalsValuesList->GetCount(); x++)
{
int *ip = (int*)GoalsValuesList->GetClientData(x);
if(ip)
{
if(*ip == changedGoal)
{
*ip = newVal;
wxString newStr;
newStr.Printf("%u", newVal);
GoalsValuesList->SetString(x, newStr);
break;
}
}
}
vector<eqtask_goallist>::iterator Iter;
for(Iter = goalTaskList.begin(); Iter != goalTaskList.end(); Iter++)
{
if((*Iter).id == changedId && (*Iter).value == changedGoal)
{
(*Iter).value = newVal;
return;
}
}
}
void MainFrame::ContextMenuGoalList()
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Context menu cannot open, not connected to db");
return;
}
wxMenu *mMenu;
mMenu = new wxMenu();
mMenu->Append(MENU_NewGoal, wxT("New Goal"), wxT("Creates a new goal list entry"));
mMenu->Append(MENU_DeleteGoal, wxT("Delete Goal"), wxT("Deletes the selected goal list entry"));
PopupMenu(mMenu);
delete mMenu;
}
void MainFrame::ContextMenuGoalValueList()
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Context menu cannot open, not connected to db");
return;
}
wxMenu *mMenu;
mMenu = new wxMenu();
mMenu->Append(MENU_AddGoalItem, wxT("New Goal Value"), wxT("Creates a new goal value entry for the opened list"));
mMenu->Append(MENU_DeleteGoalItem, wxT("Delete Goal Value"), wxT("Deletes the selected goal value entry"));
mMenu->Append(MENU_ModifyGoalItem, wxT("Modify Goal Value"), wxT("Attempts to change the selected goal value entry"));
PopupMenu(mMenu);
delete mMenu;
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef EQWX_ITEMS__H
#define EQWX_ITEMS__H
struct eqitem{
unsigned int id;
char name[64];
};
#endif
+468
View File
@@ -0,0 +1,468 @@
#include <wx/wx.h>
#include <wx/numdlg.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
void MainFrame::ProximityListBoxDoubleClick(wxCommandEvent& event)
{
eqtask_prox *eqp = (eqtask_prox*)ProximitySelectionList->GetClientData(event.GetInt());
if(eqp){
FillProximityValues(eqp->zoneid, eqp->exploreid);
}
else{
mErrorLog->Log(eqEmuLogBoth, "ProximityListBoxDoubleClick failed, eqp is NULL");
}
}
void MainFrame::PopulateProximity()
{
mErrorLog->Log(eqEmuLogBoth, "Populating Proximity List");
vector<eqtask_proximity>::iterator Iter;
for(Iter = taskProximityList.begin(); Iter != taskProximityList.end(); Iter++)
{
eqtask_proximity eqt;
eqt = *Iter;
eqtask_prox * prox = new eqtask_prox;
prox->exploreid = eqt.exploreid;
prox->zoneid = eqt.zoneid;
wxString zoneName;
zoneName.Printf("Unknown Zone");
vector<eqtask_zones>::iterator ZoneIter;
for(ZoneIter = taskZoneList.begin(); ZoneIter != taskZoneList.end(); ZoneIter++)
{
eqtask_zones curZone = *ZoneIter;
if(curZone.id == prox->zoneid)
{
zoneName.Clear();
zoneName.Printf("%s", curZone.name);
}
}
wxString newStr;
newStr.Printf("%s - %u", zoneName.mb_str(), prox->exploreid);
ProximitySelectionList->Append(newStr, (void*)prox);
}
}
void MainFrame::FillProximityValues(unsigned int zone, unsigned int explore)
{
mErrorLog->Log(eqEmuLogBoth,"zon %u, ex %u", zone, explore);
eqtask_proximity ourProx;
vector<eqtask_proximity>::iterator Iter;
for(Iter = taskProximityList.begin(); Iter != taskProximityList.end(); Iter++)
{
eqtask_proximity curProx = *Iter;
if(curProx.exploreid == explore && curProx.zoneid == zone){
ourProx = curProx;
}
}
wxString ourStr;
ourStr.Clear();
ourStr.Printf("%u", ourProx.exploreid);
mProxId->Enable();
mProxId->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.minx);
mProxMinx->Enable();
mProxMinx->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.maxx);
mProxMaxx->Enable();
mProxMaxx->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.miny);
mProxMiny->Enable();
mProxMiny->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.maxy);
mProxMaxy->Enable();
mProxMaxy->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.minz);
mProxMinz->Enable();
mProxMinz->SetValue(ourStr);
ourStr.Clear();
ourStr.Printf("%.4f", ourProx.maxz);
mProxMaxz->Enable();
mProxMaxz->SetValue(ourStr);
openedProximity.exploreid = explore;
openedProximity.zoneid = zone;
SetZoneSelectionByIdProximity(zone);
mProxZone->Enable();
}
void MainFrame::NewProximity(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "New proximity failed, not connected to db");
return;
}
int newID = wxGetNumberFromUser("", "Explore ID:", "Explore ID", 0, 0, 9999999);
int newZoneID = wxGetNumberFromUser("", "Zone ID:", "Zone ID", 0, 0, 9999999);
if(newID < 0 || newZoneID < 0)
{
mErrorLog->Log(eqEmuLogBoth, "New proximity failed, id or zone < 0");
return;
}
if(newID == 0xFFFFFFFF || newZoneID == 0xFFFFFFF)
{
mErrorLog->Log(eqEmuLogBoth, "New proximity failed, 0xFFFFFFFF cannot be set with editor");
return;
}
eqtask_proximity newProx;
newProx.exploreid = newID;
newProx.zoneid = newZoneID;
newProx.maxx = 0.0;
newProx.minx = 0.0;
newProx.maxy = 0.0;
newProx.miny = 0.0;
newProx.maxz = 0.0;
newProx.minz = 0.0;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "INSERT INTO `proximities` (`zoneid`,`exploreid`) VALUES (%u,%u)", newZoneID, newID);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
eqtask_prox * pPtr = new eqtask_prox;
pPtr->exploreid = newID;
pPtr->zoneid = newZoneID;
wxString zoneName;
zoneName.Printf("Unknown Zone");
vector<eqtask_zones>::iterator ZoneIter;
for(ZoneIter = taskZoneList.begin(); ZoneIter != taskZoneList.end(); ZoneIter++)
{
eqtask_zones curZone = *ZoneIter;
if(curZone.id == newZoneID)
{
zoneName.Clear();
zoneName.Printf("%s", curZone.name);
}
}
wxString newStr;
newStr.Printf("%s - %u", zoneName.mb_str(), newID);
ProximitySelectionList->Append(newStr, (void*)pPtr);
taskProximityList.push_back(newProx);
}
void MainFrame::DeleteProximity(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Delete proximity failed, not connected to db");
return;
}
eqtask_prox * pPtr = (eqtask_prox*)ProximitySelectionList->GetClientData(ProximitySelectionList->GetSelection());
if(!pPtr){
mErrorLog->Log(eqEmuLogBoth, "Delete proximity failed, pPtr is NULL");
return;
}
int explore = pPtr->exploreid;
int zone = pPtr->zoneid;
int reply = wxMessageBox("Are you sure?", "Confirm Delete", wxYES_NO, this);
if(reply != wxYES)
{
mErrorLog->Log(eqEmuLogBoth, "User aborted delete of proximity.");
return;
}
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM proximities WHERE zoneid=%u AND exploreid=%u", zone, explore);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
for(unsigned int x = 0; x < ProximitySelectionList->GetCount(); x++)
{
eqtask_prox * p = (eqtask_prox*)ProximitySelectionList->GetClientData(x);
if(p){
if(p->exploreid == explore && p->zoneid == zone)
{
delete p;
p = NULL;
ProximitySelectionList->Delete(x);
break;
}
}
}
vector<eqtask_proximity>::iterator Iter;
for(Iter = taskProximityList.begin(); Iter != taskProximityList.end(); Iter++)
{
eqtask_proximity curProx = *Iter;
if(curProx.exploreid == explore && curProx.zoneid == zone){
taskProximityList.erase(Iter);
break;
}
}
if(openedProximity.exploreid == explore && openedProximity.zoneid == zone)
{
mProxId->Clear();
mProxId->Disable();
mProxMinx->Clear();
mProxMinx->Disable();
mProxMaxx->Clear();
mProxMaxx->Disable();
mProxMiny->Clear();
mProxMiny->Disable();
mProxMaxy->Clear();
mProxMaxy->Disable();
mProxMinz->Clear();
mProxMinz->Disable();
mProxMaxz->Clear();
mProxMaxz->Disable();
mProxZone->Select(0);
mProxZone->Disable();
openedProximity.exploreid = 0xFFFFFFFF;
openedProximity.zoneid = 0xFFFFFFFF;
}
}
void MainFrame::SaveProximity(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Save proximity failed, not connected to db");
return;
}
if(openedProximity.exploreid == 0xFFFFFFFF && openedProximity.zoneid == 0xFFFFFFFF)
{
mErrorLog->Log(eqEmuLogBoth, "Save proximity failed, no proximity opened");
return;
}
mErrorLog->Log(eqEmuLogBoth, "Saving proximity...");
eqtask_proximity toSave;
wxString inStr;
int explore = openedProximity.exploreid;
int zone = openedProximity.zoneid;
bool canUpdate = false;
inStr.Clear();
inStr = mProxId->GetValue();
toSave.exploreid = atoi(inStr.mb_str());
inStr.Clear();
inStr = mProxMinx->GetValue();
toSave.minx = atof(inStr.mb_str());
inStr.Clear();
inStr = mProxMaxx->GetValue();
toSave.maxx = atof(inStr.mb_str());
inStr.Clear();
inStr = mProxMiny->GetValue();
toSave.miny = atof(inStr.mb_str());
inStr.Clear();
inStr = mProxMaxy->GetValue();
toSave.maxy = atof(inStr.mb_str());
inStr.Clear();
inStr = mProxMinz->GetValue();
toSave.minz = atof(inStr.mb_str());
inStr.Clear();
inStr = mProxMaxz->GetValue();
toSave.maxz = atof(inStr.mb_str());
if(toSave.maxx < toSave.minx){
mErrorLog->Log(eqEmuLogBoth, "min x and max x mismatched, correcting");
int temp = toSave.minx;
toSave.minx = toSave.maxx;
toSave.maxx = temp;
wxString tempStr;
tempStr.Printf("%.4f", toSave.minx);
mProxMinx->SetValue(tempStr);
tempStr.Clear();
tempStr.Printf("%.4f", toSave.maxx);
mProxMaxx->SetValue(tempStr);
tempStr.Clear();
}
if(toSave.maxy < toSave.miny){
mErrorLog->Log(eqEmuLogBoth, "min y and max y mismatched, correcting");
int temp = toSave.miny;
toSave.miny = toSave.maxy;
toSave.maxy = temp;
wxString tempStr;
tempStr.Printf("%.4f", toSave.miny);
mProxMiny->SetValue(tempStr);
tempStr.Clear();
tempStr.Printf("%.4f", toSave.maxy);
mProxMaxy->SetValue(tempStr);
tempStr.Clear();
}
if(toSave.maxz < toSave.minz){
mErrorLog->Log(eqEmuLogBoth, "min z and max z mismatched, correcting");
int temp = toSave.minz;
toSave.minz = toSave.maxz;
toSave.maxz = temp;
wxString tempStr;
tempStr.Printf("%.4f", toSave.minz);
mProxMinz->SetValue(tempStr);
tempStr.Clear();
tempStr.Printf("%.4f", toSave.maxz);
mProxMaxz->SetValue(tempStr);
tempStr.Clear();
}
int * iPtr = (int*)mProxZone->GetClientData(mProxZone->GetCurrentSelection());
toSave.zoneid = *iPtr;
if(!iPtr){
mErrorLog->Log(eqEmuLogBoth, "Save proximity failed, iPtr is NULL");
return;
}
if(openedProximity.exploreid == toSave.exploreid && openedProximity.zoneid == toSave.zoneid)
{
mErrorLog->Log(eqEmuLogBoth, "Can use UPDATE");
}
else{
mErrorLog->Log(eqEmuLogBoth, "Cannot use UPDATE must replace instead");
}
if(canUpdate){
char * mQuery = 0;
MakeAnyLenString(&mQuery, "UPDATE proximities SET minx=%.4f, maxx=%.4f, miny=%.4f, maxy=%.4f, minz=%.4f, maxz=%.4f) WHERE zoneid=%u AND exploreid=%u",
toSave.minx, toSave.maxx, toSave.miny, toSave.maxy, toSave.minz, toSave.maxz, toSave.zoneid, toSave.exploreid);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
}
else
{
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM proximities WHERE zoneid=%u AND exploreid=%u", zone, explore);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
MakeAnyLenString(&mQuery, "INSERT INTO `proximities` (`zoneid`,`exploreid`,`minx`,`maxx`,`miny`,`maxy`,`minz`,`maxz`) VALUES (%u,%u,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f)"
, toSave.zoneid, toSave.exploreid, toSave.minx, toSave.maxx, toSave.miny, toSave.maxy, toSave.minz, toSave.maxz);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
}
for(unsigned int x = 0; x < ProximitySelectionList->GetCount(); x++)
{
eqtask_prox * p = (eqtask_prox*)ProximitySelectionList->GetClientData(x);
if(p){
if(p->exploreid == openedProximity.exploreid && p->zoneid == openedProximity.zoneid)
{
p->exploreid = toSave.exploreid;
p->zoneid = toSave.zoneid;
wxString newStr;
wxString zoneName;
zoneName.Printf("Unknown Zone");
vector<eqtask_zones>::iterator ZoneIter;
for(ZoneIter = taskZoneList.begin(); ZoneIter != taskZoneList.end(); ZoneIter++)
{
eqtask_zones curZone = *ZoneIter;
if(curZone.id == p->zoneid)
{
zoneName.Clear();
zoneName.Printf("%s", curZone.name);
}
}
newStr.Printf("%s - %u", zoneName.mb_str(), p->exploreid );
ProximitySelectionList->SetString(x, newStr);
break;
}
}
}
vector<eqtask_proximity>::iterator Iter;
for(Iter = taskProximityList.begin(); Iter != taskProximityList.end(); Iter++)
{
eqtask_proximity cur = *Iter;
if(cur.exploreid == openedProximity.exploreid && cur.zoneid == openedProximity.zoneid)
{
(*Iter).exploreid = toSave.exploreid;
(*Iter).zoneid = toSave.zoneid;
(*Iter).minx = toSave.minx;
(*Iter).maxx = toSave.maxx;
(*Iter).miny = toSave.miny;
(*Iter).maxy = toSave.maxy;
(*Iter).minz = toSave.minz;
(*Iter).maxz = toSave.maxz;
}
}
openedProximity.exploreid = toSave.exploreid;
openedProximity.zoneid = toSave.zoneid;
mErrorLog->Log(eqEmuLogBoth, "Save finished.");
}
void MainFrame::ContextMenuProximity()
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Context menu cannot open, not connected to db");
return;
}
wxMenu *mMenu;
mMenu = new wxMenu();
mMenu->Append(MENU_NewProximity, wxT("New Proximity"), wxT("Creates a new goal proximity entry"));
mMenu->Append(MENU_DeleteProximity, wxT("Delete Proximity"), wxT("Deletes the selected proximity entry"));
mMenu->AppendSeparator();
mMenu->Append(MENU_SaveProximity, wxT("Save Proximity"), wxT("Saves the opened proximity entry"));
PopupMenu(mMenu);
delete mMenu;
}
+328
View File
@@ -0,0 +1,328 @@
#include <wx/wx.h>
#include <wx/numdlg.h>
#include <mysql.h>
#include <vector>
#include "tasks.h"
#include "utility.h"
#include "base.h"
#include "ErrorLog.h"
using namespace std;
void MainFrame::NewTask(wxCommandEvent& event)
{
if(mMysql){
eqtask newT;
newT.id = (highestIndex+1);
newT.duration = 0;
strcpy(newT.title, "Default Task Name");
strcpy(newT.desc, "Default Task Description");
strcpy(newT.reward, "");
newT.cashreward = 0;
newT.xpreward = 0;
newT.rewardmethod = 2;
newT.rewardid = 0;
newT.startzone = -1;
newT.level_min = 0;
newT.level_max = 0;
newT.repeatable = true;
unsigned int newID = wxGetNumberFromUser("", "ID:", "Input ID", (highestIndex+1), 0, 2147483600);
newT.id = newID;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "INSERT INTO `tasks` (`id`,`duration`,`title`,`description`,`reward`,`rewardid`,`cashreward`,`xpreward`,`rewardmethod`,`startzone`, `minlevel`, `maxlevel`, `repeatable`) VALUES (%u,%u,'%s','%s','%s',%u,%u,%u,%u,%u,%u,%u,%u)",
newT.id, newT.duration, newT.title, newT.desc, newT.reward, newT.rewardid, newT.cashreward, newT.xpreward, newT.rewardmethod, newT.startzone, newT.level_min, newT.level_max, newT.repeatable);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
taskList.push_back(newT);
wxString str;
str.Printf("%d:%s", newT.id, "Default Task Name");
ItemSelectionList->Append(str);
if(highestIndex < (newID + 1))
highestIndex = newID + 1;
}
else{
mErrorLog->Log(eqEmuLogBoth, "Error with new task create, mysql not initialized");
}
}
void MainFrame::DeleteTask(wxCommandEvent& event)
{
if(selectedIndex < 0)
{
mErrorLog->Log(eqEmuLogBoth, "No item selected for delete, delete failing.");
return;
}
if(mMysql){
int reply = wxMessageBox("Are you sure?", "Confirm Delete", wxYES_NO, this);
if(reply != wxYES)
{
mErrorLog->Log(eqEmuLogBoth, "User aborted delete of task.");
return;
}
vector<eqtask>::iterator Iter;
Iter = taskList.begin();
Iter += selectedIndex;
eqtask mTask = *Iter;
char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM `tasks` WHERE id=%u", mTask.id);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
if(openedIndex == selectedIndex){
wxString mStr;
mStr.Printf("%s", "Task Name");
mTaskName->Clear();
mTaskName->AppendText(mStr);
mTaskName->Disable();
mStr.clear();
mStr.Printf("%s", "Task Description");
mTaskDesc->Clear();
mTaskDesc->AppendText(mStr);
mTaskDesc->Disable();
mStr.clear();
mStr.Printf("%u", 0);
mTaskMinLvl->Clear();
mTaskMinLvl->AppendText(mStr);
mTaskMinLvl->Disable();
mStr.clear();
mStr.Printf("%u", 0);
mTaskMaxLvl->Clear();
mTaskMaxLvl->AppendText(mStr);
mTaskMaxLvl->Disable();
mStr.clear();
mStr.Printf("%u", 0);
mTaskDuration->Clear();
mTaskDuration->AppendText(mStr);
mTaskDuration->Disable();
mStr.clear();
mRewardName->Clear();
mRewardName->Disable();
mStr.Printf("%u", 0);
mRewardID->Clear();
mRewardID->AppendText(mStr);
mRewardID->Disable();
mStr.clear();
mStr.Printf("%u", 0);
mRewardCash->Clear();
mRewardCash->AppendText(mStr);
mRewardCash->Disable();
mStr.clear();
mStr.Printf("%u", 0);
mRewardXP->Clear();
mRewardXP->AppendText(mStr);
mRewardXP->Disable();
mStr.clear();
openedIndex = -1;
mRewardMethod->Select(0);
mRewardMethod->Disable();
mStartZone->Select(0);
mStartZone->Disable();
mTaskRepeatable->SetValue(false);
mTaskRepeatable->Disable();
ShowRewardItems->Disable();
ShowRewardItems->Clear();
RefreshItems->Disable();
ClearActivities();
ActivitiesSelectionList->Disable();
openedActivity.activityid = -1;
openedActivity.id = -1;
openedActivity.step = -1;
mActText1->Clear();
mActText1->Disable();
mActText2->Clear();
mActText2->Disable();
mActText3->Clear();
mActText3->Disable();
mActivityZone->Select(0);
mActivityZone->Disable();
mActivityOptional->SetValue(false);
mActivityOptional->Disable();
mActID->Clear();
mActID->Disable();
mActStep->Clear();
mActStep->Disable();
mActType->Select(0);
mActType->Disable();
mActDeliver->Clear();
mActDeliver->Disable();
mActMethod->Select(2);
mActMethod->Disable();
mActGoalID->Clear();
mActGoalID->Disable();
mActGoalCount->Clear();
mActGoalCount->Disable();
}
taskList.erase(Iter);
ItemSelectionList->Delete(selectedIndex);
}
else{
mErrorLog->Log(eqEmuLogBoth, "Error with task delete, mysql not initialized");
}
selectedIndex = -1;
}
void MainFrame::OnRewardButton(wxCommandEvent& event)
{
wxString ridStr = mRewardID->GetValue();
int rtype = mRewardMethod->GetCurrentSelection();
int rid = atoi(ridStr.mb_str());
ShowRewardChange(rtype,rid);
}
void MainFrame::SaveTask(wxCommandEvent& event)
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Mysql not connected for save of task");
return;
}
if(openedIndex>=0){
mErrorLog->Log(eqEmuLogBoth, "Saving task...");
vector<eqtask>::iterator Iter;
Iter = taskList.begin();
Iter += openedIndex;
eqtask ourTask = *Iter;
wxString getStr;
getStr = mTaskName->GetValue();
strcpy(ourTask.title, getStr.mb_str());
getStr.Clear();
getStr = mTaskDesc->GetValue();
strcpy(ourTask.desc, getStr.mb_str());
getStr.Clear();
getStr = mTaskMinLvl->GetValue();
ourTask.level_min = atoi(getStr.mb_str());
getStr.Clear();
getStr = mTaskMaxLvl->GetValue();
ourTask.level_max = atoi(getStr.mb_str());
getStr.Clear();
getStr = mTaskDuration->GetValue();
ourTask.duration = atoi(getStr.mb_str());
getStr.Clear();
getStr = mRewardName->GetValue();
strcpy(ourTask.reward, getStr.mb_str());
getStr.Clear();
getStr = mRewardID->GetValue();
ourTask.rewardid = atoi(getStr.mb_str());
getStr.Clear();
getStr = mRewardCash->GetValue();
ourTask.cashreward = atoi(getStr.mb_str());
getStr.Clear();
getStr = mRewardXP->GetValue();
ourTask.xpreward = atoi(getStr.mb_str());
getStr.Clear();
int * i = (int*)mStartZone->GetClientData(mStartZone->GetSelection());
ourTask.startzone = *i;
ourTask.rewardmethod = mRewardMethod->GetSelection();
ourTask.repeatable = mTaskRepeatable->GetValue();
char * mQuery = 0;
MakeAnyLenString(&mQuery, "UPDATE tasks SET duration=%u, title='%s', description='%s', reward='%s', rewardid=%u, cashreward=%u, xpreward=%i, rewardmethod=%u, startzone=%u, minlevel=%u, maxlevel=%u, repeatable=%u WHERE id=%u",
ourTask.duration, MakeStringSQLSafe(ourTask.title).mb_str(), MakeStringSQLSafe(ourTask.desc).mb_str(), MakeStringSQLSafe(ourTask.reward).mb_str(), ourTask.rewardid, ourTask.cashreward, ourTask.xpreward, ourTask.rewardmethod, ourTask.startzone, ourTask.level_min, ourTask.level_max, ourTask.repeatable, ourTask.id);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
/*char * mQuery = 0;
MakeAnyLenString(&mQuery, "DELETE FROM tasks WHERE id=%u", (*Iter).id);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}
MakeAnyLenString(&mQuery, "INSERT INTO `tasks` (`id`,`duration`,`title`,`description`,`reward`,`rewardid`,`cashreward`,`xpreward`,`rewardmethod`,`startzone`, `minlevel`, `maxlevel`) VALUES (%u,%u,'%s','%s','%s',%u,%u,%u,%u,%u,%u,%u)",
ourTask.id, ourTask.duration, MakeStringSQLSafe(ourTask.title).mb_str(), MakeStringSQLSafe(ourTask.desc).mb_str(), MakeStringSQLSafe(ourTask.reward).mb_str(), ourTask.rewardid, ourTask.cashreward, ourTask.xpreward, ourTask.rewardmethod, ourTask.startzone, ourTask.level_min, ourTask.level_max);
mErrorLog->Log(eqEmuLogSQL, "%s", mQuery);
if (mysql_query(mMysql, mQuery)) {
mErrorLog->Log(eqEmuLogBoth, "MySQL Error: %s", mysql_error(mMysql));
return;
}*/
(*Iter).cashreward = ourTask.cashreward;
strcpy((*Iter).desc, ourTask.desc);
(*Iter).duration = ourTask.duration;
(*Iter).level_max = ourTask.level_max;
(*Iter).level_min = ourTask.level_min;
strcpy((*Iter).reward, ourTask.reward);
(*Iter).rewardid = ourTask.rewardid;
(*Iter).rewardmethod = ourTask.rewardmethod;
(*Iter).startzone = ourTask.startzone;
strcpy((*Iter).title, ourTask.title);
(*Iter).xpreward = ourTask.xpreward;
(*Iter).repeatable = ourTask.repeatable;
getStr.Printf("%u:%s", (*Iter).id, (*Iter).title);
ItemSelectionList->SetString(openedIndex, getStr);
mErrorLog->Log(eqEmuLogBoth, "Save finished.");
}
else{
mErrorLog->Log(eqEmuLogBoth, "Opened index for Task Save not valid.");
}
}
void MainFrame::ContextMenuTaskList()
{
if(!mMysql){
mErrorLog->Log(eqEmuLogBoth, "Context menu cannot open, not connected to db");
return;
}
wxMenu *mMenu;
mMenu = new wxMenu();
mMenu->Append(MENU_NewTask, wxT("New Task"), wxT("Creates a new task"));
mMenu->Append(MENU_DeleteTask, wxT("Delete Task"), wxT("Deletes the selected task"));
mMenu->AppendSeparator();
mMenu->Append(MENU_SaveTask, wxT("Save Task"), wxT("Saves the opened task"));
PopupMenu(mMenu);
delete mMenu;
}
+75
View File
@@ -0,0 +1,75 @@
#ifndef EQWX_TASKS__H
#define EQWX_TASKS__H
struct eqtask
{
unsigned int id;
unsigned int duration; //i
char title[100]; //i
char desc[2047]; //i
char reward[64]; //i
unsigned int rewardid; //i
unsigned int cashreward; //i
int xpreward; //i
unsigned short rewardmethod; //i
unsigned int startzone; //i
unsigned short level_min; //i
unsigned short level_max; //i
bool repeatable;
};
struct eqtask_goallist
{
unsigned int id;
unsigned int value;
};
struct eqtask_activities
{
unsigned int id;
unsigned int activityId; //i
unsigned int step; //i
unsigned int activityType; //i
char text1[64]; //i
char text2[64]; //i
char text3[128]; //i
unsigned int goalid; //n 7 digit textbox
unsigned int goalmethod; //i
unsigned int goalcount; //n 2 digit text box
unsigned int deliverToNpc; //i
unsigned int zoneid; //i
bool optional; //i
};
struct eqtask_activity_id
{
unsigned int id;
unsigned int step;
unsigned int activityid;
};
struct eqtask_zones
{
char name[32];
unsigned int id;
};
struct eqtask_proximity
{
unsigned int exploreid;
unsigned int zoneid;
double minx;
double maxx;
double miny;
double maxy;
double minz;
double maxz;
};
struct eqtask_prox
{
unsigned int exploreid;
unsigned int zoneid;
};
#endif
+29
View File
@@ -0,0 +1,29 @@
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "utility.h"
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define safe_delete(d) if(d) { delete d; d=0; }
#define safe_delete_array(d) if(d) { delete[] d; d=0; }
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
chars = vsnprintf(*ret, buf_len, format, argptr);
}
va_end(argptr);
return chars;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef EQWX_UTILITY__H
#define EQWX_UTILITY__H
int MakeAnyLenString(char** ret, const char* format, ...);
#endif