INT_PTR TestSplitBySourceDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	IParamBlock2* pblock = NULL;

	switch(msg) {
		case WM_INITDIALOG:
			if (NumMaps() == 0) { // first map to open
				GetPFSystemPool()->RegisterNotification(UpdateSources, this);
			}
			AddMap(map);
			if (map != NULL) pblock = map->GetParamBlock();
			if (pblock != NULL)	pblock->NotifyDependents( FOREVER, (PartID)map, kSplitBySource_RefMsg_InitDlg );
			break;
		case WM_DESTROY:
			RemoveMap(map);
			if (NumMaps() == 0) { // last map to close
				GetPFSystemPool()->UnRegisterNotification(UpdateSources, this);
			}
			break;
		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDC_SOURCELIST:
					SelectSources(hWnd, map->GetParamBlock());
					break;
				case kSplitBySource_message_update:
					UpdateSourceDlg(map);
					break;
			}
			break;
	}

	return FALSE;
}
Example #2
0
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;
}
Example #3
0
void Maps::CloseMap(HWND hMap)
{
    std::shared_ptr<GuiMap> map = GetMap(hMap);
    if ( map != nullptr )
        RemoveMap(map);

    if ( openMaps.size() == 0 )
        DisableMapping();
}
Example #4
0
//=================================================================================================================
void TopdownWorld::UpdateMapName(string mapName)
{
    // Clone the current rendered map
    TopdownMap* newMap = 0;
    map<string, TopdownMap*>::iterator iter = m_world_maps.find(m_map_to_render);
    if (iter != m_world_maps.end())
    {
        newMap = (*iter).second->Clone();
    }

    // remove the current rendered map
    RemoveMap(m_map_to_render);

    // add the clone with the new map name
    m_world_maps.insert(make_pair(mapName, newMap));
}
Example #5
0
bool Maps::NewMap(u16 width, u16 height, u16 tileset, u32 terrain, u32 triggers)
{
    if ( width == 0 || height == 0 )
    {
        Error("Invalid dimensions");
        return false;
    }

    std::shared_ptr<GuiMap> newMap = AddEmptyMap();

    if ( newMap->CreateNew(width, height, tileset, terrain, triggers) )
    {
        char title[256] = { "Untitled" };
        if ( UntitledNumber > 0 )
            std::snprintf(title, 256, "Untitled %d", UntitledNumber);

        if ( newMap->CreateThis(getHandle(), title) )
        {
            UntitledNumber++;
            EnableMapping();
            Focus(newMap);
            currentlyActiveMap->Redraw(true);
            return true;
        }
        else
            Error("Failed to create MDI Child Window!");
    }
    else
    {
        CHKD_ERR("Failed to create map!\n\nError in %s\n\n%s", LastErrorLoc, LastError);
        Error(LastError);
    }

    RemoveMap(newMap);
    return false;
}