加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainFrm.cpp 69.01 KB
一键复制 编辑 原始数据 按行查看 历史
Shaker 提交于 2014-08-18 11:30 . *可编译了
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "TurboMir.h"
#include "MainFrm.h"
#include "LoginDialog.h"
#include ".\mainfrm.h"
#include "cpptooltip\PPTooltip.h"
#include "BCGExtended\ToolBarLabel.h"
#include "QuitDialog.h"
#include "afxwin.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
const int TIMER_EVENT_CHECK_ATTACK_MODE=0x815;
const char szAd[]=
"TeaM-D 传奇2外辅 私服版\n"
//"http://www.tmdwg.com/\n"
//"\n"
//"广告销售规则:\n"
//"1、 所有广告采用星期形式出租,谢绝分期付款。 \n"
//"2、 本站广告没有测试服务,先全额付费,再放广告,请遵守本站广告销售流程。 \n"
//"3、 本站不采用n元/1000ip的计费方式,均为星期广告,如果您觉得不适合您的营销策略,请勿联系本站。 \n"
//"4、 任何弹窗退窗类广告,在广告期间,一旦发现所弹窗口有违规内容,比如:自动设为首页、额外弹窗、额外退出弹窗、网页自动最大化、恶意代码等, 一律马上撤销您的弹窗。 \n"
//"5、 所有网页必须按照规格像素大小制作,尺寸正规。 \n"
//"6、 一次性投放一季度只需支付2.5个月费用;一次性投放半年只需支付5个月费用;一次性投放一年只需要要支付9个月费用。 \n"
//"7、 我们只保证本站不断的发展壮大,保证流量的不断增长,但是我们不保证能给您带来多少流量。对此,我们不能轻易做出任何承诺。 \n"
//"8、 如果您感觉无法接受以上条款,请勿联系本站。最大限度的互惠互利,希望诚信为准,公平交易。 \n"
//"\n"
//"广告投放说明:\n"
//"1、以上广告位一次性包租两个月9.2折优惠,一次性包租三个月8.5折优惠,可提前一周进行预定!\n"
//"2、先付款并款到帐后开始投放广告,如果我们查询未到帐请扫描您的汇款底单经我们确认后才给投放广告!\n"
//"3、以上已租出广告位可提前交款预定!(须联系确定后需付30%的定金)\n"
//"4、具体与 QQ:99106278\n"
//"5、除以上广告位,其它位置均可联系我们详谈!\n"
//"6、如续费,请在到期前三天联系我们确定当月价格后付款(广告价格每月可能会有所变动)!\n"
//"7、本站为个人网站,投放广告不开具发票!\n"
//"8、广告位租出后不能更换到其它位置!\n"
//"9、其他待续! \n"
//"\n"
//"注意:申请广告包月的客户必须遵循国务院292号令公布的“互联网信息服务管理办法”,您的网站不得制作、复制、发布、传播含有下列内容的信息:反对宪法所确定的基本原则的;危害国家安全,泄露国家秘密,颠覆国家政权,破坏国家统一的;损害国家荣誉和利益的;煽动 民族仇恨、民族歧视,破坏民族团结的;破坏国家宗教政策,宣扬邪教和封建迷信的;散布谣言,扰乱社会秩序,破坏社会稳定的;散布淫秽、色情、赌博、暴力、凶杀、恐怖或者教唆犯罪的;侮辱或者诽谤他人,侵害他人合法利益的;含有法律行政法规禁止的其他内容的\n"
"\n\n";
// CMessageBox
IMPLEMENT_DYNAMIC(CMessageBox, CDialogEx)
BEGIN_MESSAGE_MAP(CMessageBox, CDialogEx)
END_MESSAGE_MAP()
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CFrameWndEx)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_COMMAND_RANGE(ID_SKIN_LunaBlue, ID_SKIN_Normal, OnAppLook)
ON_UPDATE_COMMAND_UI_RANGE(ID_SKIN_LunaBlue, ID_SKIN_Normal, OnUpdateAppLook)
ON_COMMAND(ID_LOGIN, OnLogin)
ON_UPDATE_COMMAND_UI(ID_LOGIN, OnUpdateLogin)
ON_COMMAND(ID_DISCONNECT, OnDisconnect)
ON_UPDATE_COMMAND_UI(ID_DISCONNECT, OnUpdateDisconnect)
ON_UPDATE_COMMAND_UI(ID_SCRIPT_RUN, OnUpdateScriptRun)
ON_COMMAND(ID_SETTING, OnSetting)
ON_UPDATE_COMMAND_UI(ID_SETTING, OnUpdateSetting)
ON_MESSAGE(WM_ADDLOG,OnAddLog)
ON_MESSAGE(WM_DEBUGOUT,OnDebugOut)
ON_MESSAGE(WM_ADDCHAT,OnAddChat)
ON_COMMAND(ID_ATTACKMODE_CHANGE, OnAttackmodeChange)
ON_COMMAND_RANGE(ID_ATTACKMODE_0, ID_ATTACKMODE_7, OnAttackmode)
ON_UPDATE_COMMAND_UI_RANGE(ID_ATTACKMODE_0, ID_ATTACKMODE_7, OnUpdateAttackmode)
ON_UPDATE_COMMAND_UI(ID_ATTACKMODE_CHANGE, OnUpdateAttackmodeChange)
ON_COMMAND(ID_USE_ITEM, OnUseItem)
ON_WM_TIMER()
ON_COMMAND(ID_TALK_TO, OnTalkTo)
ON_COMMAND_RANGE(ID_TAKEON_1, ID_TAKEON_13, OnTakeOn)
ON_COMMAND(ID_DROP_ITEM, OnDropItem)
ON_COMMAND(ID_VIEW_ACTORS, OnViewActors)
ON_COMMAND(ID_VIEW_BAG, OnViewBag)
ON_COMMAND(ID_VIEW_DEBUG, OnViewDebug)
ON_COMMAND(ID_VIEW_DROPEDITEM, OnViewDropeditem)
ON_COMMAND(ID_VIEW_SELF, OnViewSelf)
ON_COMMAND(ID_VIEW_USEITEM, OnViewUseitem)
ON_COMMAND(ID_VIEW_SYSTEMLOG, OnViewSystemlog)
ON_UPDATE_COMMAND_UI(ID_VIEW_BAG, OnUpdateViewBag)
ON_UPDATE_COMMAND_UI(ID_VIEW_DEBUG, OnUpdateViewDebug)
ON_UPDATE_COMMAND_UI(ID_VIEW_DROPEDITEM, OnUpdateViewDropeditem)
ON_UPDATE_COMMAND_UI(ID_VIEW_ACTORS, OnUpdateViewActors)
ON_UPDATE_COMMAND_UI(ID_VIEW_SELF, OnUpdateViewSelf)
ON_UPDATE_COMMAND_UI(ID_VIEW_SYSTEMLOG, OnUpdateViewSystemlog)
ON_UPDATE_COMMAND_UI(ID_VIEW_USEITEM, OnUpdateViewUseitem)
ON_WM_SYSCOMMAND()
ON_COMMAND(ID_REFRESH_BAG, OnRefreshBag)
ON_COMMAND(ID_FIGHT_START, OnFightStart)
ON_UPDATE_COMMAND_UI(ID_FIGHT_START, OnUpdateFightStart)
ON_MESSAGE(WM_TRAY_NOTIFICATION, OnTrayNotification)
ON_COMMAND(ID_SHOW_MAIN, OnShowMain)
ON_UPDATE_COMMAND_UI(ID_SHOW_MAIN, OnUpdateShowMain)
ON_COMMAND(ID_VIEW_OBJECT_WINDOW, OnViewObjectWindow)
ON_UPDATE_COMMAND_UI(ID_VIEW_OBJECT_WINDOW, OnUpdateViewObjectWindow)
ON_COMMAND(ID_HELP_COMMAND, &CMainFrame::OnHelpCommand)
ON_COMMAND(ID_MOVE_TO, &CMainFrame::OnMoveTo)
ON_COMMAND(ID_ITEM_NOPICK, &CMainFrame::OnItemNopick)
ON_COMMAND(ID_NORMAL_PICKUP, &CMainFrame::OnNormalPickup)
ON_COMMAND(ID_FIRST_PICKUP, &CMainFrame::OnFirstPickup)
ON_COMMAND(ID_MUST_PICKUP, &CMainFrame::OnMustPickup)
ON_UPDATE_COMMAND_UI(ID_ITEM_NOPICK, &CMainFrame::OnUpdateItemNopick)
ON_UPDATE_COMMAND_UI(ID_NORMAL_PICKUP, &CMainFrame::OnUpdateItemNormalPickup)
ON_UPDATE_COMMAND_UI(ID_FIRST_PICKUP, &CMainFrame::OnUpdateItemFirstPickup)
ON_UPDATE_COMMAND_UI(ID_MUST_PICKUP, &CMainFrame::OnUpdateItemMustPickup)
ON_UPDATE_COMMAND_UI(ID_REFRESH_BAG, &CMainFrame::OnUpdateInGameEnable)
ON_UPDATE_COMMAND_UI(ID_MOVE_TO, &CMainFrame::OnUpdateInGameEnable)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_MONEY, // 钱
ID_HERO_NAME, // 角色名称
ID_HERO_JOB, // 角色名称
ID_LEVEL, // 等级
ID_SHOW_MAPNAME, // 地图显示
ID_SHOW_XY, // 当前坐标
ID_SHOW_BAG_FREE, // 包裹剩余空间
};
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
: m_Game(*this)
, m_SettingDialog(m_Game)
, m_wndMap(m_Game)
, m_wndLeftView(m_Game,*this)
, m_wndSystemLog(this)
, m_wndActors(this)
, m_wndSelf(this)
, m_wndBag(this)
, m_wndUseItem(this)
, m_wndGround(this)
#ifndef PUBLIC_EDTION
, m_wndDebug(this)
#endif
, m_TrayIcon(IDR_TRAY_MENU)
,m_wndView(new CRichEditView)
,m_MerchantDlg(m_Game)
{
InitializeCriticalSection(&m_logSC);
InitializeCriticalSection(&m_chtSC);
InitializeCriticalSection(&m_dbgSC);
m_Game.sig_EventItemShow.connect(boost::bind(&CMainFrame::OnItemShow,boost::ref(*this),_1));
m_Game.sig_EventItemHide.connect(boost::bind(&CMainFrame::OnItemHide,boost::ref(*this),_1));
m_Game.sig_HpChange.connect(boost::bind(&CMainFrame::OnHpChange,boost::ref(*this),_1,_2));
m_Game.sig_MpChange.connect(boost::bind(&CMainFrame::OnMpChange,boost::ref(*this),_1,_2));
m_Game.sig_ExpChange.connect(boost::bind(&CMainFrame::OnExpChange,boost::ref(*this),_1,_2));
m_Game.sig_WeightChange.connect(boost::bind(&CMainFrame::OnWeightChange,boost::ref(*this),_1,_2));
m_Game.sig_PositionChange.connect(boost::bind(&CMainFrame::OnPositionChange,boost::ref(*this),_1));
m_Game.sig_LogMessage.connect(boost::bind(&CMainFrame::AddLog,boost::ref(*this),_1,_2,_3,_4));
m_Game.sig_UpdateSelfInfo.connect(boost::bind(&CMainFrame::UpdateSelfInfo,boost::ref(*this)));
m_Game.sig_UpdateUseItem.connect(boost::bind(&CMainFrame::UpdateUseItem,boost::ref(*this)));
m_Game.sig_ClearBag.connect(boost::bind(&CMainFrame::ClearBag,boost::ref(*this)));
m_Game.sig_ClearActors.connect(boost::bind(&CMainFrame::ClearActors,boost::ref(*this)));
m_Game.sig_UpdateActor.connect(boost::bind(&CMainFrame::UpdateActors,boost::ref(*this),_1,_2));
m_Game.sig_UpdateBagItem.connect(boost::bind(&CMainFrame::UpdateBag,boost::ref(*this),_1,_2));
m_Game.sig_SetGameStatus.connect(boost::bind(&CMainFrame::SetTrayGameStatus,boost::ref(*this),_1));
m_Game.sig_SetPath.connect(boost::bind(&CMapView::SetPath,boost::ref(m_wndMap),_1));
m_Game.sig_MessageBox.connect(boost::bind(&CMainFrame::OnGameMessageBox,boost::ref(*this),_1,_2));
m_Game.sig_SetTarget.connect(boost::bind(&CLeftView::SetTarget,boost::ref(m_wndLeftView),_1));
m_Game.sig_TargetPosChange.connect(boost::bind(&CLeftView::OnTargetPosChange,boost::ref(m_wndLeftView),_1,_2,_3,_4));
m_Game.sig_TargetHpChange.connect(boost::bind(&CLeftView::OnTargetHpChange,boost::ref(m_wndLeftView),_1,_2,_3));
}
CMainFrame::~CMainFrame()
{
DeleteCriticalSection(&m_logSC);
DeleteCriticalSection(&m_chtSC);
DeleteCriticalSection(&m_dbgSC);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
static UINT AppArray[]=
{
ID_SKIN_Normal,
ID_SKIN_XP,
ID_SKIN_2003,
ID_SKIN_2005,
ID_SKIN_LunaBlue,
ID_SKIN_Silver,
ID_SKIN_ObsidianBlack,
ID_SKIN_Aqua,
ID_SKIN_XPNative,
};
m_nAppLook = AppArray[GetPrivateProfileInt("System","AppLook",2,(CGameMir::GetMainDir()+"\\main.ini").c_str())];
OnAppLook (m_nAppLook);
{
m_wndRibbonBar.Create (this);
//-------------------
// Load panel images:
//-------------------
m_PanelImages.SetImageSize (CSize (16, 16));
m_PanelImages.Load (IDB_TOOLBAR256);
//------------------
// Init main button:
//------------------
m_MainButton.SetImage (IDB_MAIN);
m_wndRibbonBar.SetApplicationButton (&m_MainButton, CSize (45, 45));
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonCategory* pCategoryGame = m_wndRibbonBar.AddCategory(_T("游戏\ng"), IDB_TOOLBAR256, IDB_TOOLBARLARGE);
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonPanel* pPanelNetWork = pCategoryGame->AddPanel (_T("网络\nn"), m_PanelImages.ExtractIcon (-1));
pPanelNetWork->Add (new CMFCRibbonButton (ID_LOGIN, _T("连接\nc"), 0, 0));
pPanelNetWork->Add (new CMFCRibbonButton (ID_DISCONNECT, _T("断开\nd"), 1, 1));
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonPanel* pPanelControl = pCategoryGame->AddPanel (_T("控制\nc"), m_PanelImages.ExtractIcon (-1));
pPanelControl->Add (new CMFCRibbonButton (ID_FIGHT_START, _T("开始\ns"), 2, 2));
CMFCRibbonButton* pBtnAttackMode = new CMFCRibbonButton (0, _T("攻击模式\nm"), -1, -1);
pBtnAttackMode->SetMenu (IDR_ATTACKMODE, TRUE);
pBtnAttackMode->SetAlwaysLargeImage();
pPanelControl->Add (pBtnAttackMode);
pPanelControl->Add (new CMFCRibbonButton (ID_REFRESH_BAG, _T("刷新背包\nr"), -1, -1));
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonPanel* pPanelSetting = pCategoryGame->AddPanel (_T("设置\ns"), m_PanelImages.ExtractIcon (-1));
pPanelSetting->Add (new CMFCRibbonButton (ID_SETTING, _T("设置\ns"), 4, 4));
//pPanelSetting->Add (new CMFCRibbonButton (ID_VIEW_MAP, _T("地图\ns"), 3, 3));
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonCategory* pCategoryView = m_wndRibbonBar.AddCategory(_T("查看\nv"), IDB_TOOLBAR256, IDB_TOOLBARLARGE);
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonPanel* pPanelView = pCategoryView->AddPanel (_T("视图\nw"), m_PanelImages.ExtractIcon (-1));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_STATUS_BAR, "状态栏\ns"));
pPanelView->Add (new CMFCRibbonSeparator);
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_SELF, "个人信息\ns"));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_USEITEM, "装备\ns"));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_BAG, "背包\ns"));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_ACTORS, "周围环境\ns"));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_DROPEDITEM, "地面物品\ns"));
pPanelView->Add (new CMFCRibbonSeparator);
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_SYSTEMLOG, "系统消息\ns"));
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_DEBUG, "调试窗口\ns"));
pPanelView->Add (new CMFCRibbonSeparator);
pPanelView->Add (new CMFCRibbonCheckBox (ID_VIEW_OBJECT_WINDOW, "目标\ns"));
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CMFCRibbonPanel* pPanelHero = pCategoryGame->AddPanel (_T("Hero"));
pPanelHero->Add(new CMFCRibbonLabel (_T("HP")));
pPanelHero->Add(new CMFCRibbonLabel (_T("MP")));
pPanelHero->Add(new CMFCRibbonLabel (_T("EXP")));
CMFCRibbonProgressBar*pProgressBar=new CMFCRibbonProgressBar (ID_HP_PROGRESS, 200);
pProgressBar->SetRange(0,200);
pPanelHero->Add(pProgressBar);
pProgressBar=new CMFCRibbonProgressBar (ID_MP_PROGRESS, 200);
pProgressBar->SetRange(0,200);
pPanelHero->Add(pProgressBar);
pProgressBar=new CMFCRibbonProgressBar (ID_EXP_PROGRESS, 200);
pProgressBar->SetRange(0,200);
pPanelHero->Add(pProgressBar);
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
CList<UINT, UINT> lstQATCmds;
lstQATCmds.AddTail (ID_LOGIN);
lstQATCmds.AddTail (ID_FIGHT_START);
lstQATCmds.AddTail (ID_SETTING);
m_wndRibbonBar.SetQuickAccessCommands (lstQATCmds);
// Add "Style" button to the right of tabs:
CMFCRibbonButton* pStyleButton = new CMFCRibbonButton ((UINT)-1, _T("Style\ns"), (UINT)-1, (UINT)-1);
pStyleButton->SetMenu (IDR_THEME_MENU, TRUE /* Right align */);
m_wndRibbonBar.AddToTabs (pStyleButton);
m_wndRibbonBar.AddToTabs (new CMFCRibbonButton (ID_APP_ABOUT, _T("\na"), m_PanelImages.ExtractIcon (6)));
}
if (!m_Font.CreatePointFont(9*10,"宋体"))
{
TRACE0("Failed to create Font\n");
return -1; // fail to create
}
//if (!m_wndMenuBar.Create (this))
//{
// TRACE0("Failed to create menubar\n");
// return -1; // fail to create
//}
//m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
//m_wndMenuBar.SetWindowText("菜单");
if(!m_wndHeroStatusBar.Create (this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC|
CBRS_GRIPPER | CBRS_BORDER_3D,
ID_VIEW_HERO_TOOLBAR))
{
TRACE0("Failed to create 角色消息栏\n");
return -1; // fail to create
}
m_wndHeroStatusBar.LoadToolBar (IDR_HERO_BAR, 0, 0, TRUE /* Is locked */);
m_wndHeroStatusBar.SetOwner (this);
m_wndHeroStatusBar.SetRouteCommandsViaFrame (FALSE);
m_wndHeroStatusBar.SetWindowText("角色消息栏");
if(!CreateProgress())
{
return -1;
}
//CClientDC dc (this);
//BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
//UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
//UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0;
//if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
// | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
// !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarHotID, 0, FALSE, 0, 0, uiToolbarHotID))
//{
// TRACE0("Failed to create toolbar\n");
// return -1; // fail to create
//}
//m_wndToolBar.SetWindowText("工具栏");
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators( indicators, sizeof(indicators)/sizeof(UINT) ) )
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// Create tabs window:
if (!m_wndTabs.Create (CMFCTabCtrl::STYLE_3D, CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST,CMFCTabCtrl::LOCATION_TOP))
{
TRACE0("Failed to create output tab window\n");
return -1; // fail to create
}
m_wndTabs.SetDrawFrame(FALSE);
const DWORD dwStyle =
WS_CHILD|WS_VISIBLE|/*WS_BORDER|*/ES_MULTILINE|WS_VSCROLL|ES_READONLY;
if (!m_wndView->Create( NULL, NULL, dwStyle, CRect(0,0,200,200), &m_wndTabs, IDC_RICHEDIT21, NULL ))
{
TRACE0("Failed to create output view\n");
return -1;
}
m_wndTabs.AddTab (m_wndView, _T("聊天记录"), -1);
if (!m_wndMap.Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL/*|WS_CAPTION*/,CRect(0,0,0,0),&m_wndTabs,0))
{
TRACE0("Failed to create Map view\n");
return -1;
}
m_wndTabs.AddTab (&m_wndMap, _T("游戏地图"), -1);
{
m_wndView->GetRichEditCtrl().SetBackgroundColor(FALSE,crChatBg);
CHARFORMAT cf;
ZeroMemory(&cf,sizeof(cf));
cf.dwMask=CFM_COLOR|CFM_SIZE|CFM_FACE|CFM_STRIKEOUT|CFM_BOLD|CFM_ITALIC;
cf.dwEffects=CFE_DISABLED;
cf.crTextColor=RGB(255,255,255);
cf.yHeight=175;
strcpy(cf.szFaceName,"宋体");
cf.cbSize=sizeof(cf);
m_wndView->GetRichEditCtrl().SetDefaultCharFormat(cf);
m_wndView->GetRichEditCtrl().SetWindowText(szAd);
}
#ifdef PUBLIC_EDTION
if (!m_wndAdvert.Create(CAdvert::IDD,&m_wndTabs))
{
TRACE0("Failed to create CAdvert\n");
return -1;
}
m_wndAdvert.ShowWindow(SW_SHOWNORMAL);
m_wndTabs.AddTab (&m_wndAdvert, _T("TMD 网站"), -1);
#endif
if (!m_wndLeftView.Create(CLeftView::IDD,this))
{
TRACE0("Failed to create Left view\n");
return -1;
}
m_wndLeftView.ShowWindow(SW_SHOWNORMAL);
//////////////////////////////////////////////////////////////////////////
// 系统信息
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndSystemLog.Create (_T("系统消息"), this, CRect (0, 0, 200, 200),
TRUE, 0,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle =
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|WS_VSCROLL|ES_READONLY ;
if (!m_wndSystemLog.m_wndChild.Create (dwStyle, CRect(0,0,200,200), &m_wndSystemLog, 0))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndSystemLog.m_wndChild.SetBackgroundColor(FALSE,crSysLogBg);
CHARFORMAT cf;
ZeroMemory(&cf,sizeof(cf));
cf.dwMask=CFM_COLOR|CFM_SIZE|CFM_FACE|CFM_STRIKEOUT|CFM_BOLD|CFM_ITALIC;
cf.dwEffects=CFE_DISABLED;
cf.crTextColor=RGB(255,255,255);
cf.yHeight=175;
strcpy(cf.szFaceName,"宋体");
cf.cbSize=sizeof(cf);
m_wndSystemLog.m_wndChild.SetDefaultCharFormat(cf);
}
//////////////////////////////////////////////////////////////////////////
// 调试窗口
//////////////////////////////////////////////////////////////////////////
#ifndef PUBLIC_EDTION
{
if (!m_wndDebug.Create (_T("Debug"), this, CRect (0, 0, 600, 200),
TRUE, 0,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle =
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|WS_VSCROLL|ES_READONLY ;
if (!m_wndDebug.m_wndChild.Create (dwStyle, CRect(0,0,200,200), &m_wndDebug, 0))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndDebug.m_wndChild.SetBackgroundColor(FALSE,crDebugBg);
CHARFORMAT cf;
ZeroMemory(&cf,sizeof(cf));
cf.dwMask=CFM_COLOR|CFM_SIZE|CFM_FACE|CFM_STRIKEOUT|CFM_BOLD|CFM_ITALIC;
cf.dwEffects=CFE_DISABLED;
cf.crTextColor=RGB(255,255,255);
cf.yHeight=175;
strcpy(cf.szFaceName,"宋体");
cf.cbSize=sizeof(cf);
m_wndDebug.m_wndChild.SetDefaultCharFormat(cf);
}
#endif
//////////////////////////////////////////////////////////////////////////
// 环境
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndActors.Create (_T("环境"), this, CRect (0, 0, 320, 320),
TRUE, 0,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle =
WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_SINGLESEL ;
if (!m_wndActors.m_wndChild.Create (dwStyle, CRect(0,0,200,200), &m_wndActors, IDR_ACTORS))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndActors.m_wndChild.SetExtendedStyle(m_wndActors.m_wndChild.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
//m_wndActors.m_wndChild.SetFont(font);
m_wndActors.m_wndChild.InsertColumn(0,"名字",LVCFMT_LEFT,170);
m_wndActors.m_wndChild.InsertColumn(1,"位置",LVCFMT_LEFT,90);
m_wndActors.m_wndChild.InsertColumn(2,"类型",LVCFMT_LEFT,40);
m_wndActors.m_wndChild.SetCellTextColorCallBack(this,
static_cast<UIExtended::CColorListCtrl::fGetCellTextColor>(&CMainFrame::GetCellTextColorActors));
m_wndActors.m_wndChild.SetCellBkColorCallBack(this,
static_cast<UIExtended::CColorListCtrl::fGetCellBkColor>(&CMainFrame::GetCellBkColorActors));
}
//////////////////////////////////////////////////////////////////////////
// 信息
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndSelf.Create (_T("角色"), this, CRect (0, 0, 330, 320),
TRUE, 1,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL;
if (!m_wndSelf.m_wndChild.Create ( dwStyle, CRect(0,0,200,200), &m_wndSelf, 0 ))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndSelf.m_wndChild.SetExtendedStyle(m_wndSelf.m_wndChild.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
//m_wndSelf.m_wndChild.SetFont(font);
int i=0;
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"名字"), CI_NAME);
//m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"性别"), CI_SEX);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"职业"), CI_PROF);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"等级"), CI_LEVEL);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"位置"), CI_POS);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"金币"), CI_GOLD);
//m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"配偶"), CI_SPOUSE);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"生命值"), CI_HP);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"魔法值"), CI_MP);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"防御"), CI_AC);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"魔法防御"), CI_MAC);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"攻击力"), CI_DC);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"魔法力"), CI_MC);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"道术"), CI_SC);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"经验"), CI_EXP);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"背包重量"), CI_BAGWEIGHT);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"负重"), CI_BODYWEIGHT);
m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"腕力"), CI_HANDWEIGHT);
//m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"准确"), CI_ZHUNQUE);
//m_wndSelf.m_wndChild.SetItemData(m_wndSelf.m_wndChild.InsertItem(i++,"敏捷"), CI_MINJIE);
m_wndSelf.m_wndChild.InsertColumn(0,"属性",LVCFMT_LEFT,70);
m_wndSelf.m_wndChild.InsertColumn(1,"数值",LVCFMT_LEFT,230);
}
//////////////////////////////////////////////////////////////////////////
// 装备
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndUseItem.Create (_T("装备"), this, CRect (0, 0, 330, 320),
TRUE, 1,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL;
if (!m_wndUseItem.m_wndChild.Create ( dwStyle, CRect(0,0,200,200), &m_wndUseItem, 0 ))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndUseItem.m_wndChild.SetExtendedStyle(m_wndUseItem.m_wndChild.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
//m_wndUseItem.m_wndChild.SetFont(font);
int i=0;
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"衣服"), U_DRESS);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"武器"), U_WEAPON);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"勋章"), U_RIGHTHAND);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"项链"), U_NECKLACE);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"头盔"), U_HELMET);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"左手镯"), U_ARMRINGL);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"右手镯"), U_ARMRINGR);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"左戒指"), U_RINGL);
m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"右戒指"), U_RINGR);
//m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"--"), CI_BUJUK);
//m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"腰带"), CI_BELT);
//m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"鞋子"), CI_BOOTS);
//m_wndUseItem.m_wndChild.SetItemData(m_wndUseItem.m_wndChild.InsertItem(i++,"--"), CI_CHARM);
m_wndUseItem.m_wndChild.InsertColumn(0,"位置",LVCFMT_LEFT,70);
m_wndUseItem.m_wndChild.InsertColumn(1,"物品",LVCFMT_LEFT,230);
UpdateSelfInfo();
}
//////////////////////////////////////////////////////////////////////////
// 背包
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndBag.Create (_T("背包"), this, CRect (0, 0, 320, 320),
TRUE, 1,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL;
if (!m_wndBag.m_wndChild.Create (dwStyle, CRect(0,0,200,200), &m_wndBag, IDR_USERBAG))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndBag.m_wndChild.SetExtendedStyle(m_wndBag.m_wndChild.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
//m_wndBag.m_wndChild.SetFont(font);
m_wndBag.m_wndChild.InsertColumn(0,"名称",LVCFMT_LEFT,200);
m_wndBag.m_wndChild.InsertColumn(1,"持久",LVCFMT_LEFT,100);
m_wndBag.m_wndChild.SetToolTipCallBack(this,
static_cast<UIExtended::CColorListCtrl::fGetTooltipText>(&CMainFrame::GetTooltipTextBag));
}
//////////////////////////////////////////////////////////////////////////
// 地面
//////////////////////////////////////////////////////////////////////////
{
if (!m_wndGround.Create (_T("地面"), this, CRect (0, 0, 320, 320),
TRUE, 1,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI ))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL;
if (!m_wndGround.m_wndChild.Create (dwStyle, CRect(0,0,200,200), &m_wndGround, 0))
{
TRACE0("Failed to create output view\n");
return FALSE; // fail to create
}
m_wndGround.m_wndChild.SetExtendedStyle(m_wndGround.m_wndChild.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
//m_wndBag.m_wndChild.SetFont(font);
m_wndGround.m_wndChild.InsertColumn(0,"名称",LVCFMT_LEFT,200);
m_wndGround.m_wndChild.InsertColumn(1,"位置",LVCFMT_LEFT,100);
}
//////////////////////////////////////////////////////////////////////////
// 设置停靠
//////////////////////////////////////////////////////////////////////////
//CString strMainToolbarTitle;
//strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR);
//m_wndToolBar.SetWindowText (strMainToolbarTitle);
//m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndHeroStatusBar.EnableDocking(CBRS_ALIGN_ANY);
//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndSystemLog.EnableDocking(CBRS_ALIGN_ANY);
m_wndActors.EnableDocking(CBRS_ALIGN_ANY);
m_wndSelf.EnableDocking(CBRS_ALIGN_ANY);
m_wndUseItem.EnableDocking(CBRS_ALIGN_ANY);
m_wndBag.EnableDocking(CBRS_ALIGN_ANY);
m_wndGround.EnableDocking(CBRS_ALIGN_ANY);
#ifndef PUBLIC_EDTION
m_wndDebug.EnableDocking(CBRS_ALIGN_ANY);
#endif
EnableDocking(CBRS_ALIGN_ANY);
GetDockingManager()->EnableDocking(CBRS_ALIGN_ANY);
GetDockingManager()->EnableAutoHidePanes(CBRS_ALIGN_ANY);
//DockControlBar(&m_wndMenuBar);
//DockControlBar(&m_wndToolBar);
DockPane(&m_wndHeroStatusBar);
DockPane(&m_wndSystemLog);
DockPane(&m_wndSelf);
m_wndGround.AttachToTabWnd (&m_wndSelf, DM_STANDARD, FALSE, NULL);
m_wndUseItem.AttachToTabWnd (&m_wndSelf, DM_STANDARD, FALSE, NULL);
m_wndActors.AttachToTabWnd (&m_wndSelf, DM_STANDARD, FALSE, NULL);
m_wndBag.AttachToTabWnd (&m_wndSelf, DM_STANDARD, FALSE, NULL);
#ifndef PUBLIC_EDTION
DockPane(&m_wndDebug);
m_wndDebug.DockToWindow (&m_wndSystemLog, CBRS_ALIGN_RIGHT);
#endif
m_wndStatusBar.SetPaneWidth(1,80);
m_wndStatusBar.SetPaneWidth(2,160);
m_wndStatusBar.SetPaneWidth(3,80);
m_wndStatusBar.SetPaneWidth(4,40);
m_wndStatusBar.SetPaneWidth(5,140);
m_wndStatusBar.SetPaneWidth(6,120);
m_wndStatusBar.SetPaneStyle (1, SBPS_NOBORDERS);
m_wndStatusBar.SetPaneBackgroundColor(1,crYellow);
m_bmpIcon1.LoadBitmap(IDB_BITMAP1);
m_wndStatusBar.SetPaneIcon(1, m_bmpIcon1);
m_wndStatusBar.SetPaneBackgroundColor(4,crLime);
m_SettingDialog.Create(CDialogSetting::IDD);
m_MerchantDlg.Create(CTalkToNpcDlg::IDD);
SetTitle("传2TMD (" __DATE__")");
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strMenu;
pSysMenu->AppendMenu(MF_SEPARATOR);
strMenu="关于(&A)\tF1";
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strMenu);
strMenu="退出(&C)\tCTRL+Q";
pSysMenu->AppendMenu(MF_STRING, IDM_QUITAPP, strMenu);
for(unsigned int i=0;i<pSysMenu->GetMenuItemCount();i++)
{
if(pSysMenu->GetMenuItemID(i) == SC_CLOSE)
{
pSysMenu->ModifyMenu(SC_CLOSE, MF_BYCOMMAND, SC_CLOSE, "隐藏主窗口(&H)\tALT+F4");
}
}
}
m_TrayIcon.SetNotificationWnd(this, WM_TRAY_NOTIFICATION);
SetTrayGameStatus(_T("未登陆"));
CRect rWnd,rClient;
m_wndLeftView.GetWindowRect(rWnd);
m_wndLeftView.GetClientRect(rClient);
CSize sWnd=m_wndLeftView.GetNeedSize();
rWnd.right=400+sWnd.cx+rWnd.Width()-rClient.Width();
rWnd.bottom=150+sWnd.cy+rWnd.Height()-rClient.Height();
rWnd.top=150;
rWnd.left=400;
m_wndLeftView.MoveWindow(rWnd);
SetTimer(TIMER_EVENT_CHECK_ATTACK_MODE,2000,NULL);
//m_Game.AddLog( crMessage, _T("界面初始化完毕!\n") );
//m_wndTabs.ActivateMDITab(2);
m_wndMsgBox.Create(IDD_MESSAGEBOX);
return 0;
}
void CMainFrame::SetTrayGameStatus(LPCTSTR text)
{
CString s;
if(strlen(text)>0)
{
s=_T("TeaM-D Mir2 - ");
s+=text;
m_TrayIcon.SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),s);
}
else
{
m_TrayIcon.SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),_T("TeaM-D Mir2"));
}
}
LRESULT CMainFrame::OnTrayNotification(WPARAM uID, LPARAM lEvent)
{
return m_TrayIcon.OnTrayNotification(uID, lEvent);
}
afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
UINT uiToolBarId = (UINT) wp;
switch (uiToolBarId)
{
case IDR_HERO_BAR:
m_wndHeroStatusBar.ReplaceButton (ID_LABEL_HP, CToolBarLabel(ID_LABEL_HP, _T("生命")));
m_wndHeroStatusBar.ReplaceButton (ID_LABEL_MP, CToolBarLabel(ID_LABEL_MP, _T("魔法")));
m_wndHeroStatusBar.ReplaceButton (ID_LABEL_EXP, CToolBarLabel(ID_LABEL_EXP, _T("经验")));
m_wndHeroStatusBar.ReplaceButton (ID_LABEL_BAG, CToolBarLabel(ID_LABEL_BAG, _T("背包")));
break;
}
return 0;
}
BOOL CMainFrame::CreateProgress(void)
{
CRect rect;
m_wndHeroStatusBar.SetButtonInfo(1,ID_HP_PROGRESS,TBBS_SEPARATOR,200);
m_wndHeroStatusBar.GetItemRect(1,&rect);
rect.top += 1;
rect.bottom -= 1;
m_wndHeroStatusBar.m_wndHPProgress.Create(WS_CHILD|WS_VISIBLE,rect,&m_wndHeroStatusBar,ID_HP_PROGRESS);
m_wndHeroStatusBar.m_wndHPProgress.SetTextFont(&m_Font);
m_wndHeroStatusBar.m_wndHPProgress.SetShowTextStyle(4);
m_wndHeroStatusBar.m_wndHPProgress.SetForeColour(RGB(255,0,0));
m_wndHeroStatusBar.m_wndHPProgress.SetTextForeColour(RGB(255,0,0));
m_wndHeroStatusBar.m_wndHPProgress.SetRange(0,999);
m_wndHeroStatusBar.m_wndHPProgress.SetPos(999);
m_wndHeroStatusBar.m_wndHPProgress.ShowWindow(SW_SHOW);
m_wndHeroStatusBar.SetButtonInfo(3,ID_MP_PROGRESS,TBBS_SEPARATOR,200);
m_wndHeroStatusBar.GetItemRect(3,&rect);
rect.top += 1;
rect.bottom -= 1;
m_wndHeroStatusBar.m_wndMPProgress.Create(WS_CHILD|WS_VISIBLE,rect,&m_wndHeroStatusBar,ID_MP_PROGRESS);
m_wndHeroStatusBar.m_wndMPProgress.SetTextFont(&m_Font);
m_wndHeroStatusBar.m_wndMPProgress.SetShowTextStyle(4);
m_wndHeroStatusBar.m_wndMPProgress.SetForeColour(RGB(0,0,255));
m_wndHeroStatusBar.m_wndMPProgress.SetTextForeColour(RGB(0,0,255));
m_wndHeroStatusBar.m_wndMPProgress.SetRange(0,999);
m_wndHeroStatusBar.m_wndMPProgress.SetPos(999);
m_wndHeroStatusBar.m_wndMPProgress.ShowWindow(SW_SHOW);
m_wndHeroStatusBar.SetButtonInfo(5,ID_EXP_PROGRESS,TBBS_SEPARATOR,200);
m_wndHeroStatusBar.GetItemRect(5,&rect);
rect.top += 1;
rect.bottom -= 1;
m_wndHeroStatusBar.m_wndEXPProgress.Create(WS_CHILD|WS_VISIBLE,rect,&m_wndHeroStatusBar,ID_EXP_PROGRESS);
m_wndHeroStatusBar.m_wndEXPProgress.SetTextFont(&m_Font);
m_wndHeroStatusBar.m_wndEXPProgress.SetShowTextStyle(4);
m_wndHeroStatusBar.m_wndEXPProgress.SetForeColour(RGB(135,116,116));
m_wndHeroStatusBar.m_wndEXPProgress.SetTextForeColour(RGB(135,116,116));
m_wndHeroStatusBar.m_wndEXPProgress.SetRange(0,999);
m_wndHeroStatusBar.m_wndEXPProgress.SetPos(999);
m_wndHeroStatusBar.m_wndEXPProgress.ShowWindow(SW_SHOW);
m_wndHeroStatusBar.SetButtonInfo(7,ID_BAG_PROGRESS,TBBS_SEPARATOR,200);
m_wndHeroStatusBar.GetItemRect(7,&rect);
rect.top += 1;
rect.bottom -= 1;
m_wndHeroStatusBar.m_wndBagProgress.Create(WS_CHILD|WS_VISIBLE,rect,&m_wndHeroStatusBar,ID_BAG_PROGRESS);
m_wndHeroStatusBar.m_wndBagProgress.SetTextFont(&m_Font);
m_wndHeroStatusBar.m_wndBagProgress.SetShowTextStyle(3);
m_wndHeroStatusBar.m_wndBagProgress.SetForeColour(RGB(240,0,240));
m_wndHeroStatusBar.m_wndBagProgress.SetTextForeColour(RGB(240,0,240));
m_wndHeroStatusBar.m_wndBagProgress.SetRange(0,999);
m_wndHeroStatusBar.m_wndBagProgress.SetPos(999);
m_wndHeroStatusBar.m_wndBagProgress.ShowWindow(SW_SHOW);
return TRUE;
}
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if ( nID == IDM_ABOUTBOX )
{
theApp.OnAppAbout();
return;
}
if ( nID == IDM_QUITAPP )
{
PostMessage(WM_COMMAND,ID_APP_EXIT);
return;
}
if ( nID == SC_CLOSE )
{
CQuitDialog dlg;
if (dlg.DoModal()==IDOK)
PostMessage(WM_COMMAND,ID_APP_EXIT);
else
PostMessage(WM_COMMAND,ID_SHOW_MAIN);
return;
}
CFrameWndEx::OnSysCommand(nID, lParam);
}
struct sLogItem
{
CTime time;
std::string text;
COLORREF crFont,crBack;
};
void CMainFrame::AddLog( sLogMessageType type, COLORREF font, COLORREF back, LPCTSTR body )
{
sLogItem log;
log.time=CTime::GetCurrentTime();
switch(type)
{
case LMT_DEBUG:
log.text=body;
SendMessage(WM_DEBUGOUT,0,(LPARAM)&log);
break;
case LMT_SYSTEM:
log.time=CTime::GetCurrentTime();
log.text=body;
log.crFont=font;
SendMessage(WM_ADDLOG,0,(LPARAM)&log);
break;
case LMT_CHAT:
log.time=CTime::GetCurrentTime();
log.text=body;
log.crFont=font;
log.crBack=back;
SendMessage(WM_ADDCHAT,0,(LPARAM)&log);
break;
}
}
LRESULT CMainFrame::OnAddLog( WPARAM , LPARAM l )
{
sLogItem* p=(sLogItem*)l;
CRichEditCtrl&edit=m_wndSystemLog.m_wndChild;
EnterCriticalSection(&m_logSC);
{
if ( edit.GetLineCount() > 1000 )
edit.SetWindowText("");
long s;
CHARFORMAT cf;
edit.GetDefaultCharFormat( cf );
cf.dwMask |= CFM_COLOR;
cf.crTextColor = crTime;
s = edit.GetTextLength();
edit.SetSel( s, -1 );
edit.SetSelectionCharFormat( cf );
edit.ReplaceSel( p->time.Format( "%H:%M:%S " ) );
edit.GetDefaultCharFormat( cf );
cf.dwMask |= CFM_COLOR;
cf.crTextColor = p->crFont;
s = edit.GetTextLength();
edit.SetSel( s, -1 );
edit.SetSelectionCharFormat( cf );
edit.ReplaceSel( p->text.c_str() );
edit.SendMessage( EM_SCROLL, SB_PAGEDOWN, 0 );
}
LeaveCriticalSection(&m_logSC);
return 0;
}
LRESULT CMainFrame::OnDebugOut( WPARAM , LPARAM l )
{
sLogItem* p=(sLogItem*)l;
CRichEditCtrl&edit=m_wndDebug.m_wndChild;
EnterCriticalSection(&m_dbgSC);
{
if ( edit.GetLineCount() > 1000 )
edit.SetWindowText("");
long s;
CHARFORMAT cf;
edit.GetDefaultCharFormat( cf );
cf.dwMask |= CFM_COLOR;
cf.crTextColor = crTime;
s = edit.GetTextLength();
edit.SetSel( s, -1 );
edit.SetSelectionCharFormat( cf );
edit.ReplaceSel( p->time.Format( "%H:%M:%S " ) );
edit.GetDefaultCharFormat( cf );
cf.dwMask |= CFM_COLOR;
cf.crTextColor = crDebug;
s = edit.GetTextLength();
edit.SetSel( s, -1 );
edit.SetSelectionCharFormat( cf );
edit.ReplaceSel( p->text.c_str() );
edit.SendMessage( EM_SCROLL, SB_PAGEDOWN, 0 );
}
LeaveCriticalSection(&m_dbgSC);
return 0;
}
LRESULT CMainFrame::OnAddChat( WPARAM , LPARAM l )
{
sLogItem* p=(sLogItem*)l;
CRichEditCtrl & edit=m_wndView->GetRichEditCtrl();
EnterCriticalSection(&m_chtSC);
{
if ( edit.GetLineCount() > 1000 )
{
edit.SetWindowText(szAd);
}
long s;
CHARFORMAT2 cf2;
ZeroMemory(&cf2,sizeof(CHARFORMAT2));
edit.GetDefaultCharFormat(cf2);
cf2.dwMask|=CFM_COLOR;
cf2.crTextColor=crTime;
s=edit.GetTextLength();
edit.SetSel(s,-1);
edit.SetSelectionCharFormat(cf2);
edit.ReplaceSel(p->time.Format("%H:%M:%S "));
ZeroMemory(&cf2,sizeof(CHARFORMAT2));
edit.GetDefaultCharFormat(cf2);
cf2.dwMask|=CFM_COLOR|CFM_BACKCOLOR;
cf2.dwEffects&=~CFE_AUTOBACKCOLOR;
cf2.crBackColor=p->crBack;
cf2.crTextColor=p->crFont;
s=edit.GetTextLength();
edit.SetSel(s,-1);
edit.SetSelectionCharFormat(cf2);
edit.ReplaceSel(p->text.c_str());
edit.SendMessage(EM_SCROLL,SB_PAGEDOWN,0);
}
LeaveCriticalSection(&m_chtSC);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWndEx::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWndEx::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWndEx::Dump(dc);
}
#endif //_DEBUG
// CMainFrame message handlers
void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/)
{
// forward focus to the view window
m_wndView->SetFocus();
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_wndView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// otherwise, do default handling
return CFrameWndEx::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
BOOL CMainFrame::OnShowPopupMenu (CMFCPopupMenu* pMenuPopup)
{
//---------------------------------------------------------
// Replace ID_VIEW_TOOLBARS menu item to the toolbars list:
//---------------------------------------------------------
CFrameWndEx::OnShowPopupMenu (pMenuPopup);
if (pMenuPopup != NULL &&
pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0)
{
if (CMFCToolBar::IsCustomizeMode ())
{
//----------------------------------------------------
// Don't show toolbars list in the cuztomization mode!
//----------------------------------------------------
return FALSE;
}
pMenuPopup->RemoveAllItems ();
CMenu menu;
VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE);
}
return TRUE;
}
void CMainFrame::OnAppLook(UINT id)
{
m_nAppLook = id;
switch (id)
{
case ID_SKIN_Normal:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager));
CDockingManager::SetDockingMode (DT_STANDARD);
WritePrivateProfileString("System","AppLook","0",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_XP:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP));
CDockingManager::SetDockingMode (DT_STANDARD);
WritePrivateProfileString("System","AppLook","1",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_2003:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003));
CDockingManager::SetDockingMode (DT_STANDARD);
WritePrivateProfileString("System","AppLook","2",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_2005:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005));
CDockingManager::SetDockingMode (DT_SMART);
WritePrivateProfileString("System","AppLook","3",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_XPNative:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows));
CDockingManager::SetDockingMode (DT_STANDARD);
WritePrivateProfileString("System","AppLook","8",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_LunaBlue:
case ID_SKIN_Silver:
case ID_SKIN_ObsidianBlack:
case ID_SKIN_Aqua:
CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D;
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007));
CDockingManager::SetDockingMode (DT_SMART);
switch (id)
{
case ID_SKIN_LunaBlue:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue);
WritePrivateProfileString("System","AppLook","4",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_Silver:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver);
WritePrivateProfileString("System","AppLook","5",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_ObsidianBlack:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
WritePrivateProfileString("System","AppLook","6",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
case ID_SKIN_Aqua:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua);
WritePrivateProfileString("System","AppLook","7",(CGameMir::GetMainDir()+"\\main.ini").c_str());
break;
}
break;
default:
ASSERT (FALSE);
}
CDockingManager* pDockManager = GetDockingManager();
if (pDockManager != NULL)
{
ASSERT_VALID (pDockManager);
pDockManager->AdjustPaneFrames();
}
CTabbedPane::ResetTabs();
RecalcLayout ();
RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI)
{
#if !defined _AFXDLL || defined _BCGCBPRO_STATIC_
pCmdUI->Enable(FALSE);
#endif
pCmdUI->SetCheck( m_nAppLook == pCmdUI->m_nID );
}
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle , CWnd* pParentWnd , CCreateContext* pContext)
{
BOOL retval=CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext);
HICON hIcon=AfxGetApp()->LoadIcon(nIDResource);
if(hIcon)
{
SetIcon(hIcon,FALSE);
SetIcon(hIcon,TRUE);
return retval;
}
else
{
return FALSE;
}
}
void CMainFrame::OnLogin()
{
CLoginDialog loginDlg;
if(loginDlg.DoModal()==IDOK)
m_Game.Login(loginDlg.ret_ServerAddress,loginDlg.ret_ServerName,loginDlg.ret_ServerPort,
loginDlg.ret_Account,loginDlg.ret_Password,loginDlg.ret_CharSelect);
}
void CMainFrame::OnUpdateLogin(CCmdUI *pCmdUI)
{
if(m_Game.m_hSocket!=INVALID_SOCKET)
{
pCmdUI->Enable(FALSE);
}
else
{
pCmdUI->Enable(TRUE);
}
}
void CMainFrame::OnDisconnect()
{
m_Game.Close();
}
void CMainFrame::OnUpdateDisconnect(CCmdUI *pCmdUI)
{
if(m_Game.m_hSocket!=INVALID_SOCKET)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CMainFrame::UpdateActors(const CGameMir::sActor& actor, bool update)
{
CListCtrl &lst=m_wndActors.m_wndChild;
int cnt=lst.GetItemCount();
int i;
if ( update )
{
bool found=false;
for ( i=0; i<cnt; i++)
{
if ( static_cast<DWORD>( lst.GetItemData(i))==actor.ServerId )
{
found=true;
break;
}
}
if ( !found )
{
i=lst.InsertItem(cnt,"");
lst.SetItemData(i,actor.ServerId);
}
lst.SetItemText( i, 0, actor.Name.c_str() );
char str[32];
sprintf(str,"(%u,%u)%s",actor.xx,actor.yy,DirStr[actor.dir&7]);
lst.SetItemText( i, 1, str );
switch( actor.Type )
{
case CGameMir::AT_Human:
lst.SetItemText( i, 2, "玩家" );
break;
case CGameMir::AT_Monst:
lst.SetItemText( i, 2, "怪物" );
break;
case CGameMir::AT_Baby:
lst.SetItemText( i, 2, "宠物" );
break;
case CGameMir::AT_Merchant:
lst.SetItemText( i, 2, "商人" );
break;
case CGameMir::AT_Guard:
lst.SetItemText( i, 2, "卫士" );
break;
default:
sprintf(str,"类型%u",LOBYTE(LOWORD(actor.Feature)));
lst.SetItemText( i, 2, str );
break;
}
}
else
{
for ( i=0; i<cnt; i++)
{
if ( static_cast<DWORD>( lst.GetItemData(i))==actor.ServerId )
{
lst.DeleteItem( i );
}
}
}
m_wndLeftView.RedrawMiniMap();
}
void CMainFrame::OnPositionChange( POINT p )
{
char buf[64];
sprintf(buf,"地图:%s[%s]",m_Game.GetSelfInfo().MapTitle.c_str(),m_Game.m_Map.get_MapName().c_str());
m_wndStatusBar.SetPaneText(5,buf);
sprintf(buf,"坐标:(%d,%d)",p.x,p.y);
m_wndStatusBar.SetPaneText(6,buf);
m_wndLeftView.RedrawMiniMap();
m_wndMap.Invalidate(FALSE);
}
void CMainFrame::UpdateSelfInfo(void)
{
const char szJobName[8][8]={"武士","法士","道士","未知"};
int count=m_wndSelf.m_wndChild.GetItemCount();
char str[256];
const CGameMir::sMySelf&self=m_Game.GetSelfInfo();
ltoa(self.Gold,str,10);
m_wndStatusBar.SetPaneText(1,str);
sprintf(str,"角色:%s",self.Name.c_str());
m_wndStatusBar.SetPaneText(2,str);
sprintf(str,"职业:%s",szJobName[self.Job>3?3:self.Job]);
m_wndStatusBar.SetPaneText(3,str);
sprintf(str,"LV%02d",self.Ability.bLevel);
m_wndStatusBar.SetPaneText(4,str);
for(int i=0;i<count;i++)
{
DWORD_PTR d=m_wndSelf.m_wndChild.GetItemData(i);
switch(d)
{
case CI_NAME:
m_wndSelf.m_wndChild.SetItemText(i,1,self.Name.c_str());
break;
case CI_POS:
//sprintf(str,"%s(%u/%u)",m_CharSelf.MapTitle.c_str(),m_CharSelf.xx,m_CharSelf.yy);
//m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_SEX:
//ltoa(m_CharSelf.sex,str,10);
m_wndSelf.m_wndChild.SetItemText(i,1,"**");
break;
case CI_GOLD:
ltoa(self.Gold,str,10);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_SPOUSE:
m_wndSelf.m_wndChild.SetItemText(i,1,"无配偶");
break;
case CI_HP:
sprintf(str,"%u/%u",self.Ability.Hp,self.Ability.MaxHp);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_MP:
sprintf(str,"%u/%u",self.Ability.Mp,self.Ability.MaxMp);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_PROF:
switch(self.Job)
{
case 0:
m_wndSelf.m_wndChild.SetItemText(i,1,"武士");
break;
case 1:
m_wndSelf.m_wndChild.SetItemText(i,1,"法师");
break;
case 2:
m_wndSelf.m_wndChild.SetItemText(i,1,"道士");
break;
default:
m_wndSelf.m_wndChild.SetItemText(i,1,"未知职业");
break;
}
break;
case CI_LEVEL:
ltoa(self.Ability.bLevel,str,10);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_AC:
sprintf(str,"%u-%u",self.Ability.ACLow,self.Ability.ACHi);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_MAC:
sprintf(str,"%u-%u",self.Ability.MACLow,self.Ability.MACHi);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_DC:
sprintf(str,"%u-%u",self.Ability.DCLow,self.Ability.DCHi);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_MC:
sprintf(str,"%u-%u",self.Ability.MCLow,self.Ability.MCHi);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_SC:
sprintf(str,"%u-%u",self.Ability.SCLow,self.Ability.SCHi);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_EXP:
str[0]=static_cast<char>(0);
if ( self.Ability.MaxExp!=0 )
{
sprintf(str,"%u/%u %2.1f%%",self.Ability.Exp,self.Ability.MaxExp,((float)self.Ability.Exp*100)/((float)self.Ability.MaxExp));
}
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_BAGWEIGHT:
sprintf(str,"%u/%u",self.Ability.BagWeight,self.Ability.MaxBagWeight);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_BODYWEIGHT:
sprintf(str,"%u/%u",self.Ability.BodyWeight,self.Ability.MaxBodyWeight);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_HANDWEIGHT:
sprintf(str,"%u/%u",self.Ability.HandWeight,self.Ability.MaxHandWeight);
m_wndSelf.m_wndChild.SetItemText(i,1,str);
break;
case CI_ZHUNQUE:
case CI_MINJIE:
break;
case CI_NONE:
m_wndSelf.m_wndChild.SetItemText(i,1,"-------------");
break;
default:
m_wndSelf.m_wndChild.SetItemText(i,1,"");
break;
}
}
}
void CMainFrame::UpdateUseItem(void)
{
int count=m_wndUseItem.m_wndChild.GetItemCount();
for(int i=0;i<count;i++)
{
DWORD_PTR d=m_wndUseItem.m_wndChild.GetItemData(i);
char buf[32];
m_wndUseItem.m_wndChild.SetItemText(i,1,GetDelphiString(m_Game.GetUseItem(i).S.Name,14,buf));
}
}
void CMainFrame::UpdateBag( const sClientItem& ci, bool isAdd )
{
int cnt=m_wndBag.m_wndChild.GetItemCount();
if ( isAdd )
{
char str[16];
ZeroMemory(str,16);
strncpy(str,ci.S.Name,min(ci.S.NameLen,sizeof(ci.S.Name)));
int idx=m_wndBag.m_wndChild.InsertItem(cnt,str);
m_wndBag.m_wndChild.SetItemData(idx,ci.MakeIndex);
sprintf(str,"%u/%u",ci.Dura/1000,ci.DuraMax/1000);
m_wndBag.m_wndChild.SetItemText(idx,1,str);
}
else
{
--cnt;
for ( ; cnt>=0; --cnt )
{
bool found=false;
DWORD id=m_wndBag.m_wndChild.GetItemData( cnt );
if(id==ci.MakeIndex)
{
m_wndBag.m_wndChild.DeleteItem(cnt);
}
}
}
int c=m_Game.GetBagItemCount();
char buf[64];
sprintf(buf,"背包剩余%u",46-c);
m_wndStatusBar.SetPaneText(7,buf);
}
void CMainFrame::OnItemShow( CGameMir::sDropedItem& di )
{
int cnt=m_wndGround.m_wndChild.GetItemCount();
int idx;
char str[16];
for ( idx=0; idx<cnt; idx++ )
{
DWORD id=m_wndGround.m_wndChild.GetItemData( idx );
if ( id==di.ServerId )
{
break;
}
}
if ( idx==cnt )
{
idx=m_wndGround.m_wndChild.InsertItem(cnt,di.Name.c_str());
m_wndGround.m_wndChild.SetItemData(idx,di.ServerId);
}
else
m_wndGround.m_wndChild.SetItemText(idx,0,di.Name.c_str());
sprintf(str,"(%u,%u)",di.x,di.y);
m_wndGround.m_wndChild.SetItemText(idx,1,str);
}
void CMainFrame::OnItemHide( CGameMir::sDropedItem& di )
{
int cnt=m_wndGround.m_wndChild.GetItemCount();
--cnt;
for ( ; cnt>=0; --cnt )
{
DWORD id=m_wndGround.m_wndChild.GetItemData( cnt );
if ( id==di.ServerId )
{
m_wndGround.m_wndChild.DeleteItem(cnt);
}
}
}
void CMainFrame::OnUpdateScriptRun(CCmdUI *pCmdUI)
{
if ( m_Game.isInGame( ) )
pCmdUI->Enable( TRUE );
else
pCmdUI->Enable( FALSE );
}
void CMainFrame::OnSetting()
{
m_SettingDialog.ShowWindow(SW_SHOW);
}
void CMainFrame::OnUpdateSetting(CCmdUI *pCmdUI)
{
if ( m_Game.isInGame( ) )
pCmdUI->Enable( TRUE );
else
pCmdUI->Enable( FALSE );
}
void CMainFrame::OnAttackmodeChange()
{
}
void CMainFrame::OnAttackmode(UINT nID)
{
int mode=nID-ID_ATTACKMODE_0;
if (mode>7)
return;
m_Game.ChangeAttackMode(mode);
}
void CMainFrame::OnUpdateAttackmode(CCmdUI *pCmdUI)
{
if ( m_Game.isInGame( ) )
pCmdUI->Enable( TRUE );
else
pCmdUI->Enable( FALSE );
int mode=pCmdUI->m_nID-ID_ATTACKMODE_0;
if ( mode==m_Game.GetAttackMode() )
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnUpdateAttackmodeChange(CCmdUI *pCmdUI)
{
if ( m_Game.isInGame( ) )
pCmdUI->Enable( TRUE );
else
pCmdUI->Enable( FALSE );
}
void CMainFrame::OnUseItem()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
m_Game.EatItem(listCtrl.GetItemData(listCtrl.m_CurSel),listCtrl.GetItemText(listCtrl.m_CurSel,0));
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
switch( nIDEvent )
{
case TIMER_HP_PROTECT:
if(m_Game.isInGame())
m_Game.OnHpChange(m_Game.GetSelf().Ability.Hp,m_Game.GetSelf().Ability.MaxHp);
break;
case TIMER_MP_PROTECT:
if(m_Game.isInGame())
m_Game.OnMpChange(m_Game.GetSelf().Ability.Mp,m_Game.GetSelf().Ability.MaxMp);
break;
case TIMER_EVENT_CHECK_ATTACK_MODE:
if(m_Game.isInGame())
m_Game.CheckAttackMode();
break;
}
CFrameWndEx::OnTimer(nIDEvent);
}
CString CMainFrame::GetTooltipTextBag( LVHITTESTINFO& li,UIExtended::CColorListCtrl& ctrl,CString& retVal)
{
DWORD itemid=ctrl.GetItemData(li.iItem);
std::list<sClientItem>::iterator item=m_Game.FindItem(itemid);
CString strTemp;
char strBuf[64];
retVal.Empty();
//名称
retVal = _T("<center><font color=blue size=12pt style=b>");
retVal += GetDelphiString(item->S.Name,14,strBuf);
retVal += _T("</font></center><br><hr color = green><br>");
switch( item->S.StdMode )
{
case 0:
if( item->S.AC != 0 )
{
strTemp.Format("+%dHP<br>",item->S.AC);
retVal += strTemp;
}
if( item->S.MAC != 0 )
{
strTemp.Format("+%dMP<br>",item->S.MAC);
retVal += strTemp;
}
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
case 1:
case 2:
case 3:
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
case 4:
switch ( item->S.Shape )
{
case 0:
if ( m_Game.GetSelfInfo().Job==0 && m_Game.GetSelfInfo().Ability.bLevel>=item->S.DuraMax )
retVal += "武术秘技<br>";
else
retVal += "<font color=red>武术秘技</font><br>";
break;
case 1:
if ( m_Game.GetSelfInfo().Job==0 && m_Game.GetSelfInfo().Ability.bLevel>=item->S.DuraMax )
retVal += "魔法书<br>";
else
retVal += "<font color=red>魔法书</font><br>";
break;
case 2:
if ( m_Game.GetSelfInfo().Job==0 && m_Game.GetSelfInfo().Ability.bLevel>=item->S.DuraMax )
retVal += "道士秘技<br>";
else
retVal = "<font color=red>道士秘技</font><br>";
break;
}
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
case 5:
case 6:
//名称
retVal = _T("<center><font color=blue size=12pt style=b>");
if ( (item->S.ItemDesc&1)!=0 )
{
retVal += "(*)";
}
retVal += GetDelphiString(item->S.Name,14,strBuf);
retVal += _T("</font></center><br><hr color = green><br>");
//重量
strTemp.Format("重量 %d 持久 %d/%d<br>",item->S.Weight,item->Dura / 1000,item->DuraMax / 1000);
retVal += strTemp;
//攻击力
if( item->S.DC != 0 || item->S.MaxDC != 0)
{
strTemp.Format("攻击 %d-%d<br>",item->S.DC,item->S.MaxDC);
retVal += strTemp;
}
//魔攻
if( item->S.MC != 0 || item->S.MaxMC != 0)
{
strTemp.Format("魔法 %d-%d<br>",item->S.MC,item->S.MaxMC);
retVal += strTemp;
}
//道术
if( item->S.SC != 0 || item->S.MaxSC != 0)
{
strTemp.Format("道术 %d-%d<br>",item->S.SC,item->S.MaxSC);
retVal += strTemp;
}
if ( item->S.SpecialPwr>0 && item->S.SpecialPwr<=10)
{
strTemp.Format("神圣+%d<br>",item->S.SpecialPwr);
retVal += strTemp;
}
if( item->S.MaxAC != 0)
{
strTemp.Format("准确+%d<br>",item->S.MaxAC);
retVal += strTemp;
}
if( item->S.MaxMAC > 0)
{
if( item->S.MaxMAC > 10)
strTemp.Format("攻击速度+%d<br>",item->S.MaxMAC);
else
strTemp.Format("攻击速度-%d<br>",item->S.MaxMAC);
retVal += strTemp;
}
if( ((item->S.AC)&0x80) != 0)
{
retVal += "祝";
}
if( ((item->S.AC)&0x7f) > 0)
{
strTemp.Format("幸运+%d<br>",item->S.AC&0x7f );
retVal += strTemp;
}
if( item->S.MAC > 0)
{
strTemp.Format("诅咒+%d<br>",item->S.MAC );
retVal += strTemp;
}
//条件
if( item->S.NeedLevel != 0)
{
switch( item->S.Need )
{
case 0:
strTemp.Format("需要等级 %d<br>",item->S.NeedLevel);
break;
case 1:
strTemp.Format("需要攻击力 %d<br>",item->S.NeedLevel);
break;
case 2:
strTemp.Format("需要魔法力 %d<br>",item->S.NeedLevel);
break;
case 3:
strTemp.Format("需要精神力 %d<br>",item->S.NeedLevel);
break;
default:
strTemp.Empty();
}
retVal += strTemp;
}
break;
case 7:
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
case 8:
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
case 10:
case 11:
//重量
strTemp.Format("重量 %d 持久 %d/%d<br>",item->S.Weight,item->Dura / 1000,item->DuraMax / 1000);
retVal += strTemp;
//防御
if( item->S.AC != 0 || item->S.MaxAC != 0)
{
strTemp.Format("防御: %d-%d<br>",item->S.AC,item->S.MaxAC);
retVal += strTemp;
}
//魔防
if( item->S.MAC != 0 || item->S.MaxMAC != 0)
{
strTemp.Format("魔防: %d-%d<br>",item->S.MAC,item->S.MaxMAC);
retVal += strTemp;
}
//攻击力
if( item->S.DC != 0 || item->S.MaxDC != 0)
{
strTemp.Format("攻击力: %d-%d<br>",item->S.DC,item->S.MaxDC);
retVal += strTemp;
}
//魔攻
if( item->S.MC != 0 || item->S.MaxMC != 0)
{
strTemp.Format("魔攻: %d-%d<br>",item->S.MC,item->S.MaxMC);
retVal += strTemp;
}
//道术
if( item->S.SC != 0 || item->S.MaxSC != 0)
{
strTemp.Format("道术: %d-%d<br>",item->S.SC,item->S.MaxSC);
retVal += strTemp;
}
//条件
if( item->S.NeedLevel != 0)
{
switch( item->S.Need )
{
case 0:
strTemp.Format("需要等级 %d<br>",item->S.NeedLevel);
break;
case 1:
strTemp.Format("需要攻击力 %d<br>",item->S.NeedLevel);
break;
case 2:
strTemp.Format("需要魔法力 %d<br>",item->S.NeedLevel);
break;
case 3:
strTemp.Format("需要精神力 %d<br>",item->S.NeedLevel);
break;
default:
strTemp.Empty();
}
retVal += strTemp;
}
break;
default:
strTemp.Format("重量 %d<br>",item->S.Weight);
retVal += strTemp;
break;
break;
}
retVal += "<hr color = blue><br>";
//类型
strTemp.Format("类型 %d<br>",item->S.StdMode);
retVal += strTemp;
//重量
strTemp.Format("重量 %d 持久 %d/%d<br>",item->S.Weight,item->Dura / 1000,item->DuraMax / 1000);
retVal += strTemp;
//防御
if( item->S.AC != 0 || item->S.MaxAC != 0)
{
strTemp.Format("防御 %d-%d<br>",item->S.AC,item->S.MaxAC);
retVal += strTemp;
}
//魔防
if( item->S.MAC != 0 || item->S.MaxMAC != 0)
{
strTemp.Format("魔防 %d-%d<br>",item->S.MAC,item->S.MaxMAC);
retVal += strTemp;
}
//攻击力
if( item->S.DC != 0 || item->S.MaxDC != 0)
{
strTemp.Format("攻击力 %d-%d<br>",item->S.DC,item->S.MaxDC);
retVal += strTemp;
}
//魔攻
if( item->S.MC != 0 || item->S.MaxMC != 0)
{
strTemp.Format("魔攻 %d-%d<br>",item->S.MC,item->S.MaxMC);
retVal += strTemp;
}
//道术
if( item->S.SC != 0 || item->S.MaxSC != 0)
{
strTemp.Format("道术 %d-%d<br>",item->S.SC,item->S.MaxSC);
retVal += strTemp;
}
//条件
if( item->S.NeedLevel != 0)
{
switch( item->S.Need )
{
case 0:
strTemp.Format("需要等级 %d<br>",item->S.NeedLevel);
break;
case 1:
strTemp.Format("需要攻击 %d<br>",item->S.NeedLevel);
break;
case 2:
strTemp.Format("需要魔法 %d<br>",item->S.NeedLevel);
break;
case 3:
strTemp.Format("需要精神力 %d<br>",item->S.NeedLevel);
break;
default:
strTemp.Empty();
}
retVal += strTemp;
}
return retVal;
}
COLORREF CMainFrame::GetCellTextColorActors ( int item, int subitem, UIExtended::CColorListCtrl& ctrl )
{
DWORD id=ctrl.GetItemData(item);
CGameMir::itActor actor=m_Game.FindActor(id);
if ( !m_Game.isOverEnd(actor) )
{
switch( actor->Type )
{
case CGameMir::AT_Human:
return RGB(0x00,0x00,0x60);
break;
case CGameMir::AT_Monst:
return crRed;
break;
case CGameMir::AT_Baby:
return crGreen;
break;
case CGameMir::AT_Guard:
case CGameMir::AT_Merchant:
return crBlue;
break;
default:
break;
}
}
return crBlack;
}
COLORREF CMainFrame::GetCellBkColorActors ( int item, int subitem, UIExtended::CColorListCtrl& ctrl )
{
DWORD id=ctrl.GetItemData(item);
CGameMir::itActor actor=m_Game.FindActor(id);
if ( !m_Game.isOverEnd(actor) )
{
switch( actor->Type )
{
case CGameMir::AT_Human:
//return RGB(0xf0,0xf0,0xf0);
break;
case CGameMir::AT_Monst:
return RGB(0xff,0xf0,0xf0);
break;
case CGameMir::AT_Baby:
return RGB(0xf0,0xff,0xf0);
break;
case CGameMir::AT_Guard:
case CGameMir::AT_Merchant:
return RGB(0xf0,0xf0,0xff);
break;
default:
break;
}
}
return crWhite;
}
void CMainFrame::OnTalkTo()
{
UIExtended::CColorListCtrl &listCtrl=m_wndActors.m_wndChild;
m_Game.ClickNPC(listCtrl.GetItemData(listCtrl.m_CurSel));
}
void CMainFrame::OnTakeOn(UINT nID)
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
DWORD idx=listCtrl.GetItemData(listCtrl.m_CurSel);
m_Game.TakeOnItem(idx,nID-ID_TAKEON_1);
}
void CMainFrame::OnDropItem()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
DWORD idx=listCtrl.GetItemData(listCtrl.m_CurSel);
char buf[16];
m_Game.SendMsg(CM_DROPITEM,idx,0,0,0,GetDelphiString(m_Game.FindItem(idx)->S.Name,14,buf));
}
void CMainFrame::OnViewActors()
{
ShowPane (&m_wndActors,
!(m_wndActors.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewActors(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndActors.IsVisible ());
}
void CMainFrame::OnViewBag()
{
ShowPane (&m_wndBag,
!(m_wndBag.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewBag(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndBag.IsVisible ());
}
void CMainFrame::OnViewDebug()
{
#if !defined(PUBLIC_EDTION)
ShowPane (&m_wndDebug,
!(m_wndDebug.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
#endif
}
void CMainFrame::OnUpdateViewDebug(CCmdUI *pCmdUI)
{
#if !defined(PUBLIC_EDTION)
pCmdUI->SetCheck (m_wndDebug.IsVisible ());
#endif
}
void CMainFrame::OnViewDropeditem()
{
ShowPane (&m_wndGround,
!(m_wndGround.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewDropeditem(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndGround.IsVisible ());
}
void CMainFrame::OnViewSelf()
{
ShowPane (&m_wndSelf,
!(m_wndSelf.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewSelf(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndSelf.IsVisible ());
}
void CMainFrame::OnViewUseitem()
{
ShowPane (&m_wndUseItem,
!(m_wndUseItem.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewUseitem(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndUseItem.IsVisible ());
}
void CMainFrame::OnViewSystemlog()
{
ShowPane (&m_wndSystemLog,
!(m_wndSystemLog.IsVisible ()),
FALSE, TRUE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewSystemlog(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_wndSystemLog.IsVisible ());
}
void CMainFrame::OnRefreshBag()
{
m_Game.RefreshBag();
}
void CMainFrame::OnFightStart()
{
if ( m_Game.GetFight() )
m_Game.StopFight();
else
m_Game.OpenFight();
}
void CMainFrame::OnUpdateFightStart(CCmdUI *pCmdUI)
{
if ( m_Game.isInGame( ) )
pCmdUI->Enable( TRUE );
else
pCmdUI->Enable( FALSE );
if ( m_Game.GetFight() )
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
if ( m_Game.GetFight() )
pCmdUI->SetText("自动战斗\t战斗中...");
else
pCmdUI->SetText("自动战斗\t开始战斗!!");
}
void CMainFrame::OnHpChange( long Hp, long MaxHp )
{
m_wndHeroStatusBar.m_wndHPProgress.SetRange(0,MaxHp);
m_wndHeroStatusBar.m_wndHPProgress.SetPos(Hp);
m_wndHeroStatusBar.m_wndHPProgress.Invalidate();
SetProgressPos (Hp*200/MaxHp, ID_HP_PROGRESS);
}
void CMainFrame::OnMpChange( long Mp, long MaxMp )
{
m_wndHeroStatusBar.m_wndMPProgress.SetRange(0,m_Game.GetSelf().Ability.MaxMp);
m_wndHeroStatusBar.m_wndMPProgress.SetPos(m_Game.GetSelf().Ability.Mp);
m_wndHeroStatusBar.m_wndMPProgress.Invalidate();
SetProgressPos (Mp*200/MaxMp, ID_MP_PROGRESS);
}
void CMainFrame::OnExpChange( long Exp, long MaxExp )
{
m_wndHeroStatusBar.m_wndEXPProgress.SetRange(0,m_Game.GetSelf().Ability.MaxExp);
m_wndHeroStatusBar.m_wndEXPProgress.SetPos(m_Game.GetSelf().Ability.Exp);
m_wndHeroStatusBar.m_wndEXPProgress.Invalidate();
SetProgressPos (Exp*200/MaxExp, ID_EXP_PROGRESS);
}
void CMainFrame::OnWeightChange( long Wt, long MaxWt )
{
m_wndHeroStatusBar.m_wndBagProgress.SetRange(0,m_Game.GetSelf().Ability.MaxBagWeight);
m_wndHeroStatusBar.m_wndBagProgress.SetPos(m_Game.GetSelf().Ability.BagWeight);
m_wndHeroStatusBar.m_wndBagProgress.Invalidate();
}
void CMainFrame::OnShowMain()
{
if ( IsWindowVisible() )
{
m_wndLeftView.ShowWindow(SW_HIDE);
ShowWindow(SW_HIDE);
}
else
{
m_wndLeftView.ShowWindow(SW_SHOW);
ShowWindow(SW_SHOW);
}
}
void CMainFrame::OnUpdateShowMain(CCmdUI *pCmdUI)
{
if ( IsWindowVisible() )
pCmdUI->SetText("隐藏主窗口(&H)\tTeaM-D");
else
pCmdUI->SetText("显示主窗口(&H)\tTeaM-D");
}
void CMainFrame::OnViewObjectWindow()
{
if ( m_wndLeftView.IsWindowVisible() )
{
m_wndLeftView.ShowWindow(SW_HIDE);
}
else
{
m_wndLeftView.ShowWindow(SW_SHOWNA);
}
}
void CMainFrame::OnUpdateViewObjectWindow(CCmdUI *pCmdUI)
{
if ( m_wndLeftView.IsWindowVisible() )
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnHelpCommand()
{
// TODO: 在此添加命令处理程序代码
}
void CMainFrame::OnMoveTo()
{
UIExtended::CColorListCtrl &listCtrl=m_wndActors.m_wndChild;
DWORD id=listCtrl.GetItemData(listCtrl.m_CurSel);
m_Game.l_TalkNpc(m_Game.FindActor(id)->Name.c_str(),m_Game.l_GetMapName(),m_Game.FindActor(id)->xx,m_Game.FindActor(id)->yy);
}
//////////////////////////////////////////////////////////////////////////////
void CMainFrame::OnItemNopick()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
m_Game.m_SettingMgr.m_ItemTactic[name].PickType=PT_NOPICK;
m_Game.m_SettingMgr.SaveItems();
}
void CMainFrame::OnUpdateItemNopick(CCmdUI *pCmdUI)
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
if ( m_Game.m_SettingMgr.m_ItemTactic.find(name)!=m_Game.m_SettingMgr.m_ItemTactic.end())
pCmdUI->SetRadio(m_Game.m_SettingMgr.m_ItemTactic[name].PickType==PT_NOPICK);
else
pCmdUI->SetRadio(FALSE);
}
//////////////////////////////////////////////////////////////////////////////
void CMainFrame::OnNormalPickup()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
m_Game.m_SettingMgr.m_ItemTactic[name].PickType=PT_NORMAL;
m_Game.m_SettingMgr.SaveItems();
}
void CMainFrame::OnUpdateItemNormalPickup(CCmdUI *pCmdUI)
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
if ( m_Game.m_SettingMgr.m_ItemTactic.find(name)!=m_Game.m_SettingMgr.m_ItemTactic.end())
pCmdUI->SetRadio(m_Game.m_SettingMgr.m_ItemTactic[name].PickType==PT_NORMAL);
else
pCmdUI->SetRadio(FALSE);
}
//////////////////////////////////////////////////////////////////////////////
void CMainFrame::OnFirstPickup()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
m_Game.m_SettingMgr.m_ItemTactic[name].PickType=PT_PICKBETTER;
m_Game.m_SettingMgr.SaveItems();
}
void CMainFrame::OnUpdateItemFirstPickup(CCmdUI *pCmdUI)
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
if ( m_Game.m_SettingMgr.m_ItemTactic.find(name)!=m_Game.m_SettingMgr.m_ItemTactic.end())
pCmdUI->SetRadio(m_Game.m_SettingMgr.m_ItemTactic[name].PickType==PT_PICKBETTER);
else
pCmdUI->SetRadio(FALSE);
}
//////////////////////////////////////////////////////////////////////////////
void CMainFrame::OnMustPickup()
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
m_Game.m_SettingMgr.m_ItemTactic[name].PickType=PT_MUSTPICK;
m_Game.m_SettingMgr.SaveItems();
}
void CMainFrame::OnUpdateItemMustPickup(CCmdUI *pCmdUI)
{
UIExtended::CColorListCtrl &listCtrl=m_wndBag.m_wndChild;
std::string name=listCtrl.GetItemText(listCtrl.m_CurSel,0);
if ( m_Game.m_SettingMgr.m_ItemTactic.find(name)!=m_Game.m_SettingMgr.m_ItemTactic.end())
pCmdUI->SetRadio(m_Game.m_SettingMgr.m_ItemTactic[name].PickType==PT_MUSTPICK);
else
pCmdUI->SetRadio(FALSE);
}
void CMainFrame::OnGameMessageBox(LPCTSTR lpText,UINT uType)
{
MyMessageBox(lpText,"消息",uType);
}
int CMainFrame::MyMessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
{
CRect rect;
m_wndMsgBox.m_Text.SetWindowText(lpText);
m_wndMsgBox.SetWindowText(lpCaption);
m_wndMsgBox.ShowWindow(SW_SHOW);
GetWindowRect(rect);
int mx=(rect.left+rect.right)/2,my=(rect.top+rect.bottom)/2;
m_wndMsgBox.MoveWindow(mx-150,my-100,300,200);
m_wndMsgBox.GetClientRect(rect);
m_wndMsgBox.m_Text.MoveWindow(10,10,rect.Width()-20,rect.Height()-50);
m_wndMsgBox.m_btnOK.MoveWindow(rect.Width()/2-30,rect.Height()-40,60,30);
return 0;
}
void CMainFrame::OnUpdateInGameEnable(CCmdUI *pCmdUI)
{
if(m_Game.isInGame())
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CMainFrame::SetProgressPos (int nPos, UINT nID)
{
CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> ar;
m_wndRibbonBar.GetElementsByID (nID, ar);
for (int i = 0; i < ar.GetSize (); i++)
{
CMFCRibbonProgressBar* pProgress = DYNAMIC_DOWNCAST (CMFCRibbonProgressBar, ar[i]);
if (pProgress != NULL)
{
if (pProgress->GetPos () != nPos)
{
pProgress->SetPos (nPos);
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化