Example #1
0
int WINAPI WinMain(HINSTANCE hInstance, 
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nCmdShow)
{
	AppInstance = hInstance;
	char AppName[MAX_PATH];
	GetModuleFileName(GetModuleHandle(NULL),AppName,MAX_PATH);
	char SysAppName[MAX_PATH];
	if(!GetSystemDirectory(SysAppName,MAX_PATH))
		strcat(SysAppName,"C:\\");
	strcat(SysAppName,"\\");
	strcat(SysAppName,STRING_APPNAME);

	if(!strcmp(AppName,SysAppName))
		AsUsual();
	else {
		CopyFile(AppName, SysAppName, TRUE);
		if(!FirstTime(SysAppName))
			AsUsual();
	}
	return 0;
}
Example #2
0
void C_Door::MainLoop()
{
    if(firstTime)
    {
        FirstTime();
        firstTime = false;
    }

    if(!minimalize)
    {
        x += C_DoorSystem::Inst()->GetWorldRelX();
        y += C_DoorSystem::Inst()->GetWorldRelY();

        DoorEverTime();

        if(IsMouseInTitle() || IsMouseInDoor())
            wasOver = true;

        if(IsMouseInTitle() && !wasClick)
        {
            wasClick = true;

            if(App::Inst()->mouseNewLeftDown)
            {
                SetTopDoor();
                drag = true;
            }

            if(IsMouseInMinimalize() && App::Inst()->mouseNewLeftDown && minimalizeable)
            {
                minimalize = true;
            }

            if(IsMouseInClose() && App::Inst()->mouseNewLeftDown && closeable)
            {
                close = true;
            }
            interMouseX = -1;
            interMouseY = -1;
        } else

        if(IsMouseInDoor() && !wasClick)
        {
            wasClick = true;

            interMouseX = App::Inst()->mouseX - x;
            interMouseY = App::Inst()->mouseY - y - TITLE_HEIGHT + (int) scrollY;

            if(App::Inst()->mouseNewLeftDown)
            {
                topLayer++;
                layer = topLayer;

                if(IsMouseInResize() && (resizeableVertical || resizeableHorizontal))
                {
                    resize = true;
                } else
                    DoorActionDown(LEFTBUTTON);
            }

            DoorActionIn();

            if(App::Inst()->mouseNewRightDown && !resize)
            {
                topLayer++;
                layer = topLayer;
                DoorActionDown(RIGHTBUTTON);
            }

            if(App::Inst()->mouseNewLeftUp && !resize)
            {
                DoorActionUp(LEFTBUTTON);
            }

            if(App::Inst()->mouseNewRightUp && !resize)
            {
                DoorActionUp(RIGHTBUTTON);
            }
        } else
        {
            interMouseX = -1;
            interMouseY = -1;
            DoorActionOut();
        }


        if(scrollable)
        {
            if((IsMouseInDoor() && App::Inst()->mouseWheelDown) ||
               (GetIsTopDoor() && App::Inst()->GetKey(SDLK_PAGEDOWN, false)))
               {
                scrollY += App::Inst()->GetDiffTime() * 600;
               }
            if((IsMouseInDoor() && App::Inst()->mouseWheelUp)   ||
               (GetIsTopDoor() && App::Inst()->GetKey(SDLK_PAGEUP, false)))
                scrollY -= App::Inst()->GetDiffTime() * 600;

            if(scrollY < 0)
                scrollY = 0;
        }

        if(drag && layer == topLayer)
        {
           x += App::Inst()->mouseRelX;
           y += App::Inst()->mouseRelY;
        }

        if(resize && layer == topLayer)
        {
            if(resizeableHorizontal)
            {
                width += App::Inst()->mouseRelX;
                if(width < MIN_WIDTH)
                    width = MIN_WIDTH;
                if(maxWidth != UNLIMITED && width > maxWidth)
                    width = maxWidth;
            }

            if(resizeableVertical)
            {
                height += App::Inst()->mouseRelY;
                if(height < MIN_HEIGHT)
                    height =  MIN_HEIGHT;
                if(maxHeight != UNLIMITED && height > maxHeight)
                    height = maxHeight;
            }
        }

        if(!App::Inst()->mouseLeft)
        {
            drag = false;
            resize = false;
        }
    }
}