Пример #1
0
Control* findControl(int Type, int LocaleID, int Disabled, int PosX, int PosY, int SizeX, int SizeY)
{
	if(ClientState() != ClientStateMenu)
		return NULL;

	char* localeStr = NULL; 
	if(LocaleID >= 0)
	{
		localeStr = UnicodeToAnsi(D2LANG_GetLocaleText((WORD)LocaleID));
		if(!localeStr)
			return NULL;
		Control* res = findControl(Type, localeStr, Disabled, PosX, PosY, SizeX, SizeY);
		delete[] localeStr;
		return res;
	}

	return NULL;
}
Пример #2
0
bool OOG_CreateGame(const wchar_t* name, const wchar_t* pass, int difficulty) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    // reject name/password combinations over 15 characters
    if (!name || !pass || wcslen(name) > 15 || wcslen(pass) > 15)
        return FALSE;

    Control* pControl = NULL;

    // Battle.net/open game creation
    OOG_Location loc = OOG_GetLocation();
    if (!(loc == OOG_LOBBY || loc == OOG_CHAT || loc == OOG_DIFFICULTY || loc == OOG_CREATE))
        return FALSE;

    if (loc == OOG_DIFFICULTY) {
        // just click the difficulty button
        Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 297, 272, 35),
                *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 340, 272, 35),
                *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 383, 272, 35);

        switch (difficulty) {
        case 0: // normal button
            if (normal->dwDisabled != 0x0d || !clickControl(normal))
                return FALSE;
            break;
        case 1: // nightmare button
            if (nightmare->dwDisabled != 0x0d || !clickControl(nightmare))
                return FALSE;
            break;
        case 2: // hell button
            if (hell->dwDisabled != 0x0d || !clickControl(hell))
                return FALSE;
            break;
        case 3: // hardest difficulty available
            if (hell->dwDisabled != 0x0d) {
                if (!clickControl(hell))
                    return FALSE;
            } else if (nightmare->dwDisabled != 0x0d) {
                if (!clickControl(nightmare))
                    return FALSE;
            } else if (normal->dwDisabled != 0x0d) {
                if (!clickControl(normal))
                    return FALSE;
            }
            break;
        default:
            return FALSE;
        }
    } else {
        // Create button
        if (loc != OOG_CREATE) {
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 533, 469, 120, 20);
            if (!pControl || !clickControl(pControl))
                return FALSE;
            Sleep(100);
        }
        if (OOG_GetLocation() == OOG_CREATE) {
            // Game name edit box
            if (name)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 162, 158, 20), name);
            else
                return FALSE;
            Sleep(100);

            // Password edit box
            if (pass)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 217, 158, 20), pass);
            else
                return FALSE;
            Sleep(100);
            Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 430, 381, 16, 16),
                    *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 555, 381, 16, 16),
                    *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 698, 381, 16, 16);

            switch (difficulty) {
            case 0: // normal button
                if (normal->dwDisabled == 0x4 || !clickControl(normal))
                    return FALSE;
                break;
            case 1: // nightmare button
                if (nightmare->dwDisabled == 0x4 || !clickControl(nightmare))
                    return FALSE;
                break;
            case 2: // hell button
                if (hell->dwDisabled == 0x4 || !clickControl(hell))
                    return FALSE;
                break;
            case 3: // hardest difficulty available
                if (hell->dwDisabled != 0x4) {
                    if (!clickControl(hell))
                        return FALSE;
                } else if (nightmare->dwDisabled != 0x4) {
                    if (!clickControl(nightmare))
                        return FALSE;
                } else if (normal->dwDisabled != 0x4) {
                    if (!clickControl(normal))
                        return FALSE;
                }
                break;
            default:
                return FALSE;
            }

            // Create Game Button
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 594, 433, 172, 32);
            if (!pControl || !clickControl(pControl))
                return FALSE;
        }
    }

    return TRUE;
}
Пример #3
0
OOG_Location OOG_GetLocation(void) {
    if (ClientState() != ClientStateMenu)
        return OOG_NONE;

    if (findControl(CONTROL_BUTTON, 5103, -1, 330, 416, 128, 35))
        return OOG_MAIN_MENU_CONNECTING; // 21 Connecting to Battle.net
    else if (findControl(CONTROL_BUTTON, 5102, -1, 335, 412, 128, 35))
        return OOG_LOGIN_ERROR;                                       // 10 Login Error
    else if (findControl(CONTROL_BUTTON, 5102, -1, 351, 337, 96, 32)) // 5102 =OK
    {
        if (findControl(CONTROL_TEXTBOX, 5351, -1, 268, 320, 264, 120))
            return OOG_LOST_CONNECTION; // 17 lost connection
        else if (findControl(CONTROL_TEXTBOX, 5347, -1, 268, 320, 264, 120))
            return OOG_DISCONNECTED; // 14  Disconnected
        else if (findControl(6, (const wchar_t*)NULL, -1, 265, 206, 272, 35))
            return OOG_UNABLE_TO_CONNECT_TCPIP;
        else
            return OOG_CHARACTER_CREATE_ALREADY_EXISTS;                 // 30 Character Create - Dupe Name
    } else if (findControl(CONTROL_BUTTON, 5103, -1, 351, 337, 96, 32)) // 5103 = CANCEL
    {
        if (findControl(CONTROL_TEXTBOX, 5243, -1, 268, 300, 264, 100))
            return OOG_CHARACTER_SELECT_PLEASE_WAIT; // 16 char select please wait...
        if (findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 268, 320, 264, 120))
            return OOG_PLEASE_WAIT; // 25 "Please Wait..."single player already exists also
    } else if (findControl(CONTROL_BUTTON, 5103, -1, 433, 433, 96, 32)) {
        if (findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 427, 234, 300, 100))
            return OOG_INLINE; // 2 waiting in line
        else if (findControl(CONTROL_TEXTBOX, 10018, -1, 459, 380, 150, 12))
            return OOG_CREATE; // 4 Create game
        else if (findControl(CONTROL_BUTTON, 5119, -1, 594, 433, 172, 32))
            return OOG_JOIN; // 5 Join Game
        else if (findControl(CONTROL_BUTTON, 5102, -1, 671, 433, 96, 32))
            return OOG_CHANNEL; // 7 "Channel List"
        else
            return OOG_LADDER;                                          // 6 "Ladder"
    } else if (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101 = EXIT
    {
        if (findControl(CONTROL_BUTTON, 5288, -1, 264, 484, 272, 35))
            return OOG_LOGIN; // 9 Login
        if (findControl(CONTROL_BUTTON, 5102, -1, 495, 438, 96, 32))
            return OOG_CHARACTER_SELECT_CHANGE_REALM;                                                                             // 43 char select change realm
        if (findControl(CONTROL_BUTTON, 5102, -1, 627, 572, 128, 35) && findControl(CONTROL_BUTTON, 10832, -1, 33, 528, 168, 60)) // 10832=create new
        {
            if (findControl(CONTROL_BUTTON, 10018, -1, 264, 297, 272, 35)) // NORMAL
                return OOG_DIFFICULTY;                                     // 20 single char Difficulty
            Control* pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 37, 178, 200, 92);
            if (pControl && pControl->pFirstText && pControl->pFirstText->pNext)
                return OOG_CHAR_SELECT; // 12 char select
            else {
                if (findControl(CONTROL_TEXTBOX, 11162, -1, 45, 318, 531, 140) || findControl(CONTROL_TEXTBOX, 11066, -1, 45, 318, 531, 140))
                    return OOG_REALM_DOWN;
                // Look for CONNECTING... string
                else if (findControl(CONTROL_TEXTBOX, 11065, -1, 0x2D, 0x13E, 0x213, 0x8C))
                    return OOG_CONNECTING;
                else
                    return OOG_CHARACTER_SELECT_NO_CHARS; // 42 char info not loaded
            }
        }
        if (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101=Exit
        {
            if (findControl(CONTROL_BUTTON, 5102, 0, 627, 572, 128, 35)) // 5102=ok
                return OOG_CHARACTER_CREATE;                             // 29 char create screen with char selected
            else {
                if (findControl(CONTROL_TEXTBOX, 5226, -1, 321, 448, 300, 32))
                    return OOG_NEW_ACCOUNT; // 32 create new bnet account
                else
                    return OOG_NEW_CHARACTER; // 15 char create screen no char selected
            }
        }
    }
    if (findControl(CONTROL_BUTTON, 5102, -1, 335, 450, 128, 35)) {
        if (findControl(CONTROL_TEXTBOX, 5200, -1, 162, 270, 477, 50))
            return OOG_CDKEY_IN_USE;                                         // 19 CD-KEY in use
        else if (findControl(CONTROL_TEXTBOX, 5190, -1, 162, 420, 477, 100)) // 5190="If using a modem"
            return OOG_UNABLE_TO_CONNECT;                                    // 11 unable to connect
        else
            return OOG_INVALID_CDKEY; // 22 invalid CD-KEY
    } else if (findControl(CONTROL_TEXTBOX, 5159, -1, 438, 300, 326, 150))
        return OOG_GAME_DOES_NOT_EXIST; // 28 game doesn't exist
    else if (findControl(CONTROL_TEXTBOX, 5161, -1, 438, 300, 326, 150))
        return OOG_GAME_IS_FULL; // 38 Game is full
    else if (findControl(CONTROL_TEXTBOX, 5138, -1, 438, 300, 326, 150))
        return OOG_GAME_EXIST; // 26 Game already exists
    else if (findControl(CONTROL_TEXTBOX, 5139, -1, 438, 300, 326, 150))
        return OOG_SERVER_DOWN;                                        // 24 server down
    else if (findControl(CONTROL_BUTTON, 5106, -1, 264, 324, 272, 35)) // 5106="SINGLE PLAYER"
        return OOG_MAIN_MENU;                                          // 8 Main Menu
    else if (findControl(CONTROL_BUTTON, 11126, -1, 27, 480, 120, 20)) // 11126=ENTER CHAT
        return OOG_LOBBY;                                              // 1 base bnet
    else if (findControl(CONTROL_BUTTON, 5308, -1, 187, 470, 80, 20))  // 5308="HELP"
        return OOG_CHAT;                                               // 3 chat bnet
    else if (findControl(CONTROL_TEXTBOX, 21882, -1, 100, 580, 600, 80))
        return OOG_D2SPLASH; // 18 Spash
    else if (findControl(CONTROL_BUTTON, 5102, -1, 281, 538, 96, 32))
        return OOG_GATEWAY; // 27 select gateway
    else if (findControl(CONTROL_BUTTON, 5181, -1, 525, 513, 128, 35))
        return OOG_AGREE_TO_TERMS; // 31 agree to terms
    else if (findControl(CONTROL_BUTTON, 5102, -1, 525, 513, 128, 35))
        return OOG_PLEASE_READ; // 33 please read
    else if (findControl(CONTROL_BUTTON, 11097, -1, 265, 527, 272, 35))
        return OOG_REGISTER_EMAIL; // 34 register email
    else if (findControl(CONTROL_BUTTON, 5101, -1, 33, 578, 128, 35))
        return OOG_CREDITS; // 35 Credits
    else if (findControl(CONTROL_BUTTON, 5103, -1, 334, 488, 128, 35))
        return OOG_CINEMATICS; // 36 Cinematics
    else if (findControl(CONTROL_BUTTON, 5116, -1, 264, 350, 272, 35))
        return OOG_OTHER_MULTIPLAYER; // 39 other multi player
    else if (findControl(CONTROL_BUTTON, 5103, -1, 281, 337, 96, 32))
        return OOG_ENTER_IP_ADDRESS; // 41 enter ip
    else if (findControl(CONTROL_BUTTON, 5118, -1, 265, 206, 272, 35))
        return OOG_TCP_IP; // 40 tcp-ip

    return OOG_NONE;
}
Пример #4
0
BOOL OOG_SelectGateway(const wchar_t* szGateway, size_t strSize) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    if (wcsstr(szGateway, L"ERROR"))
        return FALSE;
    // Select the gateway control.
    Control* pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 391, 272, 25);

    // if the control exists and has the text label, check if it matches the selected gateway
    if (pControl && pControl->wText2) {
        wchar_t* wzLine = _wcsdup(pControl->wText2);
        wchar_t* wzGate = _wcsdup(szGateway);
        StringToLower(wzLine);
        StringToLower(wzGate);

        if (wcsstr(wzLine, wzGate)) {
            // gateway is correct, do nothing and return true
            free(wzLine);
            free(wzGate);
            return TRUE;
        } else {
            free(wzLine);
            // gateway is NOT correct, change gateway to selected gateway if it exists
            // open the gateway select screen
            if (!clickControl(pControl))
                return FALSE;

            int index = 0;
            bool gatefound = false;

            // loop here till we find the right gateway if we can
            pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 257, 500, 292, 160);
            ControlText* cText;
            if (pControl && pControl->pFirstText) {
                cText = pControl->pFirstText;
                while (cText) {
                    wchar_t* wzGatelist = _wcsdup(cText->wText[0]);
                    if (!wzGatelist) {
                        free(wzGate);
                        return FALSE;
                    }

                    StringToLower(wzGatelist);
                    if (wcsstr(wzGatelist, wzGate)) {
                        // chosen gateway IS in the list and matches, cleanup and break the loop
                        free(wzGatelist);
                        free(wzGate);
                        gatefound = true;
                        break;
                    }
                    free(wzGatelist);
                    index++;
                    cText = cText->pNext;
                }
                if (gatefound) {
                    // click the correct gateway using the control plus a default x and a y based on (index*24)+12
                    if (!clickControl(pControl, -1, 344 + ((index * 24) + 12))) {
                        free(wzGate);
                        return FALSE;
                    }
                }
            }

            free(wzGate);

            // OK Button, gateway select screen
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 281, 538, 96, 32);
            if (pControl) {
                if (!clickControl(pControl))
                    return FALSE;
            } else
                return FALSE;

            return TRUE;
        }
    }
    return FALSE;
}
Пример #5
0
bool UI_Box::hasControl(UI_Object* pControl) const
{
    return findControl(pControl->getID()) ? true : false;
}
Пример #6
0
void LLUICtrl::initFromParams(const Params& p)
{
	LLView::initFromParams(p);

	setIsChrome(p.chrome);
	setControlName(p.control_name);
	if(p.enabled_controls.isProvided())
	{
		if (p.enabled_controls.enabled.isChosen())
		{
			LLControlVariable* control = findControl(p.enabled_controls.enabled);
			if (control)
				setEnabledControlVariable(control);
		}
		else if(p.enabled_controls.disabled.isChosen())
		{
			LLControlVariable* control = findControl(p.enabled_controls.disabled);
			if (control)
				setDisabledControlVariable(control);
		}
	}
	if(p.controls_visibility.isProvided())
	{
		if (p.controls_visibility.visible.isChosen())
		{
			LLControlVariable* control = findControl(p.controls_visibility.visible);
			if (control)
				setMakeVisibleControlVariable(control);
		}
		else if (p.controls_visibility.invisible.isChosen())
		{
			LLControlVariable* control = findControl(p.controls_visibility.invisible);
			if (control)
				setMakeInvisibleControlVariable(control);
		}
	}

	setTabStop(p.tab_stop);

	if (p.initial_value.isProvided() 
		&& !p.control_name.isProvided())
	{
        setValue(p.initial_value);
	}
	
	if (p.commit_callback.isProvided())
	{
		setCommitCallback(initCommitCallback(p.commit_callback));
	}
	
	if (p.validate_callback.isProvided())
	{
		setValidateCallback(initEnableCallback(p.validate_callback));
	}
	
	if (p.init_callback.isProvided())
	{
		if (p.init_callback.function.isProvided())
		{
			p.init_callback.function()(this, p.init_callback.parameter);
		}
		else
		{
			commit_callback_t* initfunc = (CommitCallbackRegistry::getValue(p.init_callback.function_name));
			if (initfunc)
			{
				(*initfunc)(this, p.init_callback.parameter);
			}
		}
	}

	if(p.mouseenter_callback.isProvided())
	{
		setMouseEnterCallback(initCommitCallback(p.mouseenter_callback));
	}

	if(p.mouseleave_callback.isProvided())
	{
		setMouseLeaveCallback(initCommitCallback(p.mouseleave_callback));
	}
}
Пример #7
0
//----------------------------------------------------------------------------
const char *Plugin::consoleCallback(CMDConsole *, int id,int argc,const char *argv[])
{
   if (!manager) return "False";

   switch(id)
   {   
      case GuiGetValue:
      case GuiGetVisible:
      case GuiGetActive:
      case GuiGetText:
      case GuiPerformClick:
      case TextListClear:
         if(argc != 2)
            Console->printf("%s(control);", argv[0]);
         else
         {
            Control *ctrl = findControl(argv[1]);
            if(!ctrl)
            {
               return "";
            }
            switch(id)
            {
               case GuiPerformClick:
               {
                  Event ev;
                  ev.time = GetTickCount();
                  ev.ptMouse = ctrl->localToGlobalCoord(Point2I(0,0));
                  ev.modifier = 0;
                  ev.mouseDownCount = 1;
                  ctrl->onMouseDown(ev);
                  return "";
               }
               case GuiGetValue:
                  return ctrl->getScriptValue();
               case GuiGetVisible:
                  return ctrl->isVisible() ? "True" : "False";
               case GuiGetActive: {
                  ActiveCtrl *c = dynamic_cast<ActiveCtrl*>(ctrl);
                  if(c)
                     return c->active ? "True" : "False";
                  else
                     return "False";
               }
               case GuiGetText: {
                  SimpleText *c = dynamic_cast<SimpleText*>(ctrl);
                  if(c)
                     return c->getText();
                  else
                     return "";
               }
               case TextListClear: {
                  TextList *c = dynamic_cast<TextList*>(ctrl);
                  if(c)
                     c->clear();
                  return "True";
               }
            }
         }
      case GuiSetValue:
      case GuiSetVisible:
      case GuiSetActive:
      case GuiSetText:
      case TextListAdd:
         if (argc != 3)
            Console->printf("%s(control, value);", argv[0]);
         else
         {
            Control *ctrl = findControl(argv[1]);
            if(!ctrl)
            {
               return "";
            }
            switch(id)
            {
               case GuiSetValue:
                  ctrl->setScriptValue(argv[2]);
                  break;
               case GuiSetVisible:
                  ctrl->setVisible(CMDConsole::getBool(argv[2]));
                  ctrl->setUpdate();
                  break;
               case GuiSetActive: {
                  ActiveCtrl *c = dynamic_cast<ActiveCtrl*>(ctrl);
                  if(c)
                  {
                     c->active = CMDConsole::getBool(argv[2]);
                     c->setUpdate();
                  }
                  break;
               }
               case GuiSetText: {
                  SimpleText *c = dynamic_cast<SimpleText*>(ctrl);
                  if(c)
                  {
                     c->setText(argv[2]);
                     c->setUpdate();
                  }
                  break;
               }
               case TextListAdd: {
                  TextList *c = dynamic_cast<TextList*>(ctrl);
                  if(c)
                  {
                     c->addEntryBack(argv[2]);
                     c->setUpdate();
                  }
                  break;
               }
            }
            return "True";
         }
         return "False";
   }

   Control *ctrl, *newCtrl = NULL, *newCtrlParent = NULL;
   EditControl *ectrl = NULL;
   Persistent::Base::Error err;
   Canvas *canvas = NULL;
   Canvas *root;
   SimObject *obj;
   bool argBool = FALSE;

   if(argc >= 2)
   {
      if((obj=manager->findObject(argv[1])) != NULL)
         canvas = dynamic_cast<Canvas *>(obj);
      if(!canvas)
      {
         console->printf("%s: %s is not a valid SimGui::Canvas", argv[0], argv[1]);
         return "False";
      }
      root = canvas;
      ectrl = dynamic_cast<EditControl*>(root->getMouseLockedControl());
   }
   // check the arguments here...

   switch(id)
   {
      case GuiSendToBack:
      case GuiBringToFront:
         if (argc != 2)
         {
            console->printf("%s: canvasName", argv[0]);
            return "False";
         }
         if(!ectrl)
         {
            console->printf("%s: must be in edit mode", argv[0]);
            return "False";
         }
         break;
      case SetCCursor:
         if (argc != 3)
         {
            console->printf("%s: console bitmap", argv[0]);
            return "False";
         }
         break;
      case IsCursorOn:
      case CursorOn:
      case CursorOff:
      case WindowsMouseEnable:
      case WindowsMouseDisable:

#ifdef WINKEYBOARD 
      case WindowsKeyboardEnable:
      case WindowsKeyboardDisable:
#endif
         if(argc != 2)
         {
            console->printf("%s: canvasName", argv[0]);
            return "False";
         }
         break;
      case SendRootMessage:
      case GuiJustify:
      case GuiPopDialog:
         if(argc != 3)
         {
            console->printf("%s: simCanvas int", argv[0]);
            return "False";
         }
         break;
      case SaveSelection:
         if(!ectrl)
         {
            console->printf("%s: must be in edit mode", argv[0]);
            return "False";
         }
         // fall through
      case LoadSelection:
      case LoadContent:
      case SaveContent:
      case GuiPushDialog:
         if(argc != 3)
         {
            console->printf("%s: simCanvas filename", argv[0]);
            return "False";
         }
         break;
         
      case SetCurrentAddSet:
         if (argc != 3)
         {
            console->printf("%s: simCanvas objectID", argv[0]);
            return "False";
         }
         newCtrlParent = dynamic_cast<Control *>(manager->findObject(argv[2]));
         
         break;
         
      case SetSelection:
         if (argc < 3)
         {
            console->printf("%s: simCanvas objectID <inclusive T or F>", argv[0]);
            return "False";
         }
         ctrl = dynamic_cast<Control *>(manager->findObject(argv[2]));
         
         if (argc == 4)
         {
            if (! stricmp(argv[3], "TRUE")) argBool = TRUE;
            else argBool = FALSE;
         }
         break;
         
      case EditNewControl:
      case NewContent:
         if(argc != 3)
         {
            console->printf("%s: simCanvas classname", argv[0]);
            return "False";
         }
         obj = (SimObject *) Persistent::AbstractTaggedClass::create(argv[2]);
         if(obj)
         {
            newCtrl = dynamic_cast<Control *>(obj);
            if(!newCtrl)
            {
               delete obj;
               console->printf("%s: %s is not a control class", argv[0], argv[2]);
               return "False";
            }
         }
         else
         {
            console->printf("%s: %s is not a valid class name", argv[0], argv[2]);
            return "False";
         }
         break;
      case GuiInspect:
         if(argc < 2 || argc > 3)
         {
            console->printf("%s: simCanvas [simTagDictionary]", argv[0]);
            return "False";
         }
         break;
      case EditMode:
      case GuiToolbar:
         if(argc != 2)
         {
            console->printf("%s: simCanvas", argv[0]);
            return "False";
         }
         break;
   }

   // all arguments checked
   
	switch(id) 
	{
      case SetCCursor:
         {
         // kinda hacky
         Resource<GFXBitmap> curs = SimResource::get(manager)->load(argv[2], true);
         if ((bool)curs)
		      canvas->setCursor( curs );
         else
				console->printf("%s: canvas bitmap", argv[0]);
         return "False";
         }
      case IsCursorOn:
         return(canvas->isCursorON() ? "True" : "False");
      case CursorOn:
      case CursorOff:
         canvas->setCursorON(id == CursorOn);   
         return "False";
      case WindowsMouseEnable:
         canvas->setUseWindowsMouseEvents(true);
         return "False";
      case WindowsMouseDisable:
         canvas->setUseWindowsMouseEvents(false);
         return "False";

#ifdef WINKEYBOARD
      case WindowsKeyboardEnable:
         canvas->setUseWindowsKeyboardEvents(true);
         return "False";
      case WindowsKeyboardDisable:
         canvas->setUseWindowsKeyboardEvents(false);
         return "False";
#endif

      case SendRootMessage:
         root->onMessage(NULL, atoi(argv[2]));
         return "False";
      case GuiToolbar:
         {
         SimObject *tb = manager->findObject("GuiEditBar");
         if (tb)
         {
            console->printf("GuiToolbar is already running");
            return "False";
         }

         // load up the toolbar art volume
         SimVolume* vol = new SimVolume;
         manager->addObject(vol);

	      if ( !vol->open("guiToolbar.vol")) 
			{
            manager->deleteObject(vol);
            console->printf("Could not load guiToolbar.vol");
            console->printf("copy it from phoenix/data into your exe directory");
            return "False";   
         }

			SimResource::find(manager)->addObject(vol);

         // remember root
         console->evaluate(avar("$SimGui::TBRoot = %s;", argv[1]), false); 
            
         // setup the toolbar
         console->evaluate(avar("newToolWindow(GuiEditBar, %s);", argv[1]), false); 
         console->evaluate("exec(\"guiTBSetup.cs\");", false);
         return "False";
         }
      case GuiJustify:
         {
            int just = atoi(argv[2]);
            if(just < 0 || just > 6)
            {
               console->printf("%s: justification must be 0-6", argv[0]);
               break;
            }
            ectrl->justifySelection((EditControl::Justification) just);
         }
         break;
      case GuiSendToBack:
         ectrl->sendToBack();
         break;
      case GuiBringToFront:
         ectrl->bringToFront();
         break;
      case GuiInspect:
         if(argc != 2 && argc != 3)
         {
            console->printf("GuiInspect: simCanvas [simTagDictionary]");
            break;
         }
         InspectWindow *gi;
         gi = dynamic_cast<InspectWindow *>(manager->findObject("guiInspector"));
         if (gi)
         {
            console->printf("Gui Inspector is already running");
            break;
         }
         RECT winrect;
         winrect.left = 50;
         winrect.top = 50;

         POINT cursorPos;
         if ( GetCursorPos(&cursorPos) )
         {
            winrect.left = cursorPos.x;
            winrect.top = cursorPos.y;
         }

         winrect.right = winrect.left + 30;
         winrect.bottom = winrect.top + 30;
         
         GWWindow *parent;
         parent = canvas;

         SimTagDictionary *std;
         std = NULL;
         if (argc == 3)
         {
            std = dynamic_cast<SimTagDictionary*>(manager->findObject(argv[2]));
         }
      
         gi = new InspectWindow(parent, "Gui Inspector", winrect, std);
         if (gi)
            manager->addObject(gi,"guiInspector");
         
         return (0);
      case GuiPopDialog:
         canvas->handleDLGClose(atoi(argv[2]));
         break;
      case GuiPushDialog:
         canvas->handleDLGMessage(argv[2], 0);
         break;
      case SaveSelection:
         ectrl->saveSelection(argv[2]);
         break;
      case LoadSelection:
         ectrl->loadSelection(argv[2]);
         break;
      case SaveContent:
         ctrl = root->getContentControl();
         if(!ctrl)
         {
            console->printf("No content control on root: %s", argv[1]);
            break;
         }
         err = ctrl->fileStore(argv[2]);
         if (err != Persistent::Base::Ok)
            console->printf("Error saving content control to file: %s", argv[2]);
         break;
      case LoadContent:
         if(root->inEditMode())
            root->editMode(0);

         root->handleGUIMessage(argv[2]);
         break;
      case NewContent:
         if(root->inEditMode())
            root->editMode(0);
         Control *prev;
         prev = root->getContentControl();

         manager->addObject(newCtrl);
         root->setContentControl(newCtrl, NULL);
         if(prev && prev->deleteOnLoseContent())
            prev->deleteObject();
         return 0;
         
      case SetCurrentAddSet:
         if (newCtrlParent)
         {
            if(!root->getContentControl())
            {
               console->printf("GuiSetAddSet: no content control for %s", argv[1]);
               return 0;
            }
            if(!root->inEditMode())
               root->editMode(1);
               
            ectrl = dynamic_cast<EditControl*>(root->getMouseLockedControl());
            if (ectrl) ectrl->setCurrentAddSet(newCtrlParent);
         }
         return 0;
         
      case SetSelection:
      if (ctrl)
      {
         if (!root->getContentControl())
         {
            console->printf("GuiSetSelection: no content control for %s", argv[1]);
            return 0;
         }
         if (!root->inEditMode())
         {
            root->editMode(1);
         }
            
         ectrl = dynamic_cast<EditControl*>(root->getMouseLockedControl());
         if (ectrl) ectrl->setSelection(ctrl, argBool);
      }
      return 0;
         
      case EditNewControl:
         if(!root->getContentControl())
         {
            console->printf("GuiEditNewControl: no content control for %s", argv[1]);
            return 0;
         }
         if(!root->inEditMode())
            root->editMode(1);

         ectrl = dynamic_cast<EditControl*>(root->getMouseLockedControl());
         manager->addObject(newCtrl);
         ectrl->addNewControl(newCtrl);
         return 0;
      case EditMode:
         if(root->inEditMode())
            root->editMode(0);
         else
            root->editMode(1);
         break;
	}
	return 0;
}
Пример #8
0
DWORD Profile::login(char** error)
{
	bool loginComplete = FALSE,	skippedToBnet = TRUE;
	int location = 0;
	char* errorMsg = "";
	Control* pControl = NULL;
	unsigned int timeout = 0;

	/*
		clickedOnce is needed because, when in OOG_OTHER_MULTIPLAYER
		the clickControl () is done twice and the second time it is
		failing because the button is not there anymore.
	*/
	int clickedOnce = false;

	Vars.bBlockKeys = Vars.bBlockMouse = TRUE;

	while(!loginComplete)
	{
		location = OOG_GetLocation();
		switch(location)
		{
			case OOG_D2SPLASH:
				clickControl(*p_D2WIN_FirstControl);
				break;
			case OOG_CHAR_SELECT:
				if (!OOG_SelectCharacter(charname))
					 errorMsg = "Invalid character name";
				break;
			case OOG_MAIN_MENU:
				if(type == PROFILETYPE_SINGLEPLAYER)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,324,272,35)))
						 errorMsg = "Failed to click the Single button?";
				if(type == PROFILETYPE_BATTLENET)
				{
					OOG_SelectGateway(gateway, 256);
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 366, 272, 35)))
						 errorMsg = "Failed to click the 'Battle.net' button?";
				}
				if(isOtherMP(type))
				{
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 433, 272, 35)))
						errorMsg =  "Failed to click the 'Other Multiplayer' button?";
					else
						skippedToBnet = FALSE;
				}
				break;
			case OOG_LOGIN:
				if((type == PROFILETYPE_SINGLEPLAYER || isOtherMP(type)) && skippedToBnet)
				{
					if(!clickControl(findControl(6, "EXIT", -1,33,572,128,35)))
						errorMsg =  "Failed to click the exit button?";
					break;
				}
				pControl = findControl(1, (char *)NULL, -1, 322, 342, 162, 19);
				if(pControl)
					SetControlText(pControl, username);
				else
					errorMsg = "Failed to set the 'Username' text-edit box.";
				// Password text-edit box
				pControl = findControl(1, (char *)NULL, -1, 322, 396, 162, 19);
				if(pControl)
					SetControlText(pControl, password);
				else
					errorMsg = "Failed to set the 'Password' text-edit box.";

				pControl = findControl(6, (char *)NULL, -1, 264, 484, 272, 35);
				if(pControl)
					if(!clickControl(pControl))
						errorMsg ="Failed to click the 'Log in' button?";
				timeout++;
				break;
			case OOG_DIFFICULTY:
				switch(diff)
				{
				case 0:
					// normal button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 297, 272, 35)))
						errorMsg ="Failed to click the 'Normal Difficulty' button?";
					break;
				case 1:
					// nightmare button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 340, 272, 35)))
						errorMsg =  "Failed to click the 'Nightmare Difficulty' button?";
					break;
				case 2:
					// hell button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 383, 272, 35)))
						errorMsg =  "Failed to click the 'Hell Difficulty' button?";
					break;
				default:
					errorMsg =  "Invalid single player difficulty level specified!";
					break;
				}
			case OOG_OTHER_MULTIPLAYER:
				// Open Battle.net
				if (type == PROFILETYPE_OPEN_BATTLENET)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 310, 272, 35)))
						errorMsg = "Failed to click the 'Open Battle.net' button?";
				// TCP/IP Game
				if (isTcpIp(type))
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,350,272,35)) && !clickedOnce)
						errorMsg = "Failed to click the 'TCP/IP Game' button?";
					else
						clickedOnce = true;

				break;
			case OOG_TCP_IP:
				if (type == PROFILETYPE_TCPIP_HOST)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,206,272,35)))
						errorMsg = "Failed to click the 'Host Game' button?";
				if (type == PROFILETYPE_TCPIP_JOIN)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,264,272,35)))
						errorMsg = "Failed to click the 'Join Game' button?";
				break;
			case OOG_ENTER_IP_ADDRESS:
				if (_strcmpi(ip, "")) {
					pControl = findControl(1, (char *)NULL, -1, 300, 268, -1, -1);
					if(pControl) {
						SetControlText(pControl, ip);

						// Click the OK button
						if(!clickControl(findControl(6, (char *)NULL, -1, 421, 337, 96, 32))) {
							errorMsg = "Failed to click the OK button";
						}
					} else
						errorMsg = "Failed to find the 'Host IP Address' text-edit box.";
				} else
					errorMsg = "Could not get the IP address from the profile in the d2bs.ini file.";

				break;
			case OOG_MAIN_MENU_CONNECTING: 
			case OOG_CHARACTER_SELECT_PLEASE_WAIT:
			case OOG_PLEASE_WAIT: 
			case OOG_GATEWAY:
			case OOG_CHARACTER_SELECT_NO_CHARS: 
			case OOG_CONNECTING:
			case OOG_NONE:
				timeout++;
				break;
			case OOG_LOBBY: 
			case OOG_INLINE: 
			case OOG_CHAT: 
			case OOG_CREATE:
			case OOG_JOIN: 
			case OOG_LADDER: 
			case OOG_CHANNEL: 
			case OOG_GAME_EXIST: 
			case OOG_GAME_DOES_NOT_EXIST:	
				loginComplete=TRUE;
				break;
			case OOG_UNABLE_TO_CONNECT:
				errorMsg = "Unable to connect";
				break;
			case OOG_CDKEY_IN_USE:
				errorMsg = "CD-Key in use";
				break;
			case OOG_LOGIN_ERROR:
				errorMsg = "Bad account or password";
				break;
			case OOG_REALM_DOWN:
				errorMsg = "Realm Down";
				break;
			default:
				errorMsg = "Unhandled login location";
				break;				
		}

		if(_strcmpi(errorMsg, ""))
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = errorMsg;
			return 2;
		}

		if((timeout*100) > maxLoginTime)
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = "login time out";
			return 1;
		}

		if(ClientState() == ClientStateInGame)
			loginComplete = TRUE;
		
		Sleep(100);
	}

	Vars.bBlockKeys = Vars.bBlockMouse = FALSE;

	return 0;
}
Пример #9
0
std::shared_ptr<NativeControlImpl> ResourceManager::findControlOrWindow(HWND hWnd)
{
    if( auto result = findWindow(hWnd) ) return result;
    return findControl(hWnd);
}
Пример #10
0
BOOL OOG_SelectGateway(char * szGateway, size_t strSize)
{
	if(ClientState() != ClientStateMenu)
		return FALSE;

	if(strstr(szGateway,"ERROR"))
		return FALSE;
	// Select the gateway control.
	Control* pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 264, 391, 272, 25);

	// if the control exists and has the text label, check if it matches the selected gateway
	if(pControl && pControl->wText2)
	{
		char* szLine = UnicodeToAnsi(pControl->wText2);
		if(!szLine)
			return FALSE;

		_strlwr_s(szLine, strlen(szLine)+1);
		_strlwr_s(szGateway, strSize);
		if(strstr(szLine, szGateway))
		{
			// gateway is correct, do nothing and return true
			delete[] szLine;
			return TRUE;
		}
		else
		{
			delete[] szLine;
			// gateway is NOT correct, change gateway to selected gateway if it exists
			// open the gateway select screen
			if(!clickControl(pControl))
				return FALSE;

			int index = 0;
			bool gatefound = false;

			// loop here till we find the right gateway if we can
			pControl = findControl(CONTROL_TEXTBOX, (char *)NULL, -1, 257, 500, 292, 160);
			ControlText* cText;
			if(pControl && pControl->pFirstText)
			{
				cText = pControl->pFirstText;
				while(cText)
				{
					char * szGatelist = UnicodeToAnsi(cText->wText[0]);
					if(!szGatelist)
						return FALSE;

					_strlwr_s(szGatelist, strlen(szGatelist)+1);
					if(strstr(szGatelist, szGateway))
					{
						// chosen gateway IS in the list and matches, cleanup and break the loop
						gatefound = true;
						delete[] szGatelist;
						break;
					}
					delete[] szGatelist;
					index++;
					cText = cText->pNext;
				}
				if(gatefound)
				{
				// click the correct gateway using the control plus a default x and a y based on (index*24)+12
					if(!clickControl(pControl, -1, 344+((index*24)+12)))
						return FALSE;
				}
			}

			// OK Button, gateway select screen
			pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 281, 538, 96, 32);
			if(pControl)
			{
				if(!clickControl(pControl))
					return FALSE;
			}
			else
				return FALSE;

			return TRUE;
		}
	}
	return FALSE;
}
Пример #11
0
void LLUICtrl::initFromXML(LLXMLNodePtr node, LLView* parent)
{
	std::string name;
	if(node->getAttributeString("name", name))
		setName(name);

	BOOL has_tab_stop = hasTabStop();
	node->getAttributeBOOL("tab_stop", has_tab_stop);

	setTabStop(has_tab_stop);

	node->getAttributeBOOL("requests_front", mRequestsFront);

	std::string str = node->getName()->mString;
	std::string attrib_str;
	LLXMLNodePtr child_node;

	//Since so many other callback 'types' piggyback off of the commitcallback registrar as well as use the same callback signature
	//we can assemble a nice little static list to iterate down instead of copy-pasting mostly similar code for each instance.
	//Validate/enable callbacks differ, as it uses its own registry/callback signature. This could be worked around with a template, but keeping
	//all the code local to this scope is more beneficial.
	typedef boost::signals2::connection (LLUICtrl::*commit_fn)( const commit_signal_t::slot_type& cb );
	static std::pair<std::string,commit_fn> sCallbackRegistryMap[3] = 
	{
		std::pair<std::string,commit_fn>(".commit_callback",&LLUICtrl::setCommitCallback),
		std::pair<std::string,commit_fn>(".mouseenter_callback",&LLUICtrl::setMouseEnterCallback),
		std::pair<std::string,commit_fn>(".mouseleave_callback",&LLUICtrl::setMouseLeaveCallback)
	};
	for(S32 i= 0; i < sizeof(sCallbackRegistryMap)/sizeof(sCallbackRegistryMap[0]);++i)
	{
		if(node->getChild((str+sCallbackRegistryMap[i].first).c_str(),child_node,false))
		{
			if(child_node->getAttributeString("function",attrib_str))
			{
				commit_callback_t* func = (CommitCallbackRegistry::getValue(attrib_str));
				if (func)
				{
					if(child_node->getAttributeString("parameter",attrib_str))
						(this->*sCallbackRegistryMap[i].second)(boost::bind((*func), this, LLSD(attrib_str)));
					else
						(this->*sCallbackRegistryMap[i].second)(commit_signal_t::slot_type(*func));
				}
			}
		}
	}

	if(node->getChild((str+".validate_callback").c_str(),child_node,false))
	{
		if(child_node->getAttributeString("function",attrib_str))
		{
			enable_callback_t* func = (EnableCallbackRegistry::getValue(attrib_str));
			if (func)
			{
				if(child_node->getAttributeString("parameter",attrib_str))
					setValidateCallback(boost::bind((*func), this, LLSD(attrib_str)));
				else
					setValidateCallback(enable_signal_t::slot_type(*func));
			}
		}
	}
	LLView::initFromXML(node, parent);
	
	if (node->getAttributeString("enabled_control", attrib_str))
	{
		LLControlVariable* control = findControl(attrib_str);
		if (control)
			setEnabledControlVariable(control);
	}

	if (node->getAttributeString("disabled_control", attrib_str))
	{
		LLControlVariable* control = findControl(attrib_str);
		if (control)
			setDisabledControlVariable(control);
	}

	if(node->getAttributeString("visibility_control",attrib_str) || node->getAttributeString("visiblity_control",attrib_str))
	{
		LLControlVariable* control = findControl(attrib_str);
		if (control)
			setMakeVisibleControlVariable(control);
	}
	if(node->getAttributeString("invisibility_control",attrib_str) || node->getAttributeString("invisiblity_control",attrib_str))
	{
		LLControlVariable* control = findControl(attrib_str);
		if (control)
			setMakeInvisibleControlVariable(control);
	}
}