示例#1
0
文件: Maps.cpp 项目: jjf28/Chkdraft
bool Maps::OpenMap(std::string fileName)
{
    auto newMap = AddEmptyMap();

    if ( newMap->LoadMapFile(fileName) )
    {
        if ( newMap->CreateThis(getHandle(), fileName) )
        {
            SetWindowText(newMap->getHandle(), fileName.c_str());
            EnableMapping();
            Focus(newMap);

            if ( newMap->isProtected() && newMap->hasPassword() )
                chkd.enterPasswordWindow.CreateThis(chkd.getHandle());
            else if ( newMap->isProtected() )
                mb("Map is protected and will be opened as view only");

            SetFocus(chkd.getHandle());
            currentlyActiveMap->Scroll(true, true, false);
            currentlyActiveMap->Redraw(true);
            currentlyActiveMap->refreshScenario();
            return true;
        } 
        else
            Error("Failed to create MDI Child Window!");
    }

    RemoveMap(newMap);
    return false;
}
示例#2
0
int Chkdraft::Run(LPSTR lpCmdLine, int nCmdShow)
{
    if ( !CreateThis() )
        return 1;

    scData.Load();
    InitCommonControls();
    ShowWindow(getHandle(), nCmdShow);
    UpdateWindow();
    ParseCmdLine(lpCmdLine);
    GuiMap::SetAutoBackup(true);
    this->OnLoadTest();

    MSG msg = {};
    bool keepRunning = true;
    do
    {
        while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0 )
        {
            if ( msg.message == WM_QUIT )
                keepRunning = false;
            else
            {
                bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
                if ( ::IsDialogMessage(currDialog, &msg) == FALSE )
                {
                    ::TranslateMessage(&msg);
                    if ( !isDlgKey )
                        KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
                    ::DispatchMessage(&msg);
                }
            }
        }

        if ( CM != nullptr && ColorCycler::CycleColors(CM->getTileset()) )
            CM->Redraw(false);

        std::this_thread::sleep_for(std::chrono::milliseconds(1)); // Avoid consuming a core

    } while ( keepRunning );

    /*MSG msg;
    while ( GetMessage(&msg, NULL, 0, 0) > 0 )
    {
        bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
        if ( IsDialogMessage(currDialog, &msg) == FALSE &&
             TranslateMDISysAccel(maps.getHandle(), &msg) == FALSE )
        {
            TranslateMessage(&msg);
            if ( !isDlgKey )
                KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
            DispatchMessage(&msg);
        }
    }*/
    return msg.wParam;
}