Exemplo n.º 1
0
void JBoundsEditor::SetRootPath( const char* objPath )
{
    if (m_RootPath.is_equal_ci( objPath ))
    {
        return;
    }
    m_RootPath = objPath;
    JObject* pObj = g_pObjectServer->FindObject( objPath );
    if (!pObj)
    {
        return;
    }

    if (!IsVisible())
    {
        return;
    }

    ClearEditors();

    if (m_bRootOnly)
    {
        CreateEditor( pObj );
    }
    else
    {
        JObjectIterator it( pObj );
        while (it)
        {
            JObject* pCurObject = *it;
            CreateEditor( pCurObject );
            ++it;
        }
    }
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
	if (Initialize(600, 480, argv) != 0)
	{
		return 1;
	}
	SDL_SetRenderDrawBlendMode(g_renderer, SDL_BLENDMODE_ADD);

	ModInfo* info = GetModInfo("mods/libhydorah.so");
	if (info == NULL)
		return 1;

	printf("Found mod:\n\t%s - %s\n", info->name, info->description);

	Mod* mod = CreateMod(info);

	TextureList* textures = NULL;

	Map* map = CreateMapFromFile("maps/test.map", &textures);
	Editor* editor = CreateEditor(map);

	int running = 1;
	while (running)
	{
		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			if (event.type == SDL_QUIT)
				running = 0;
			
			HandleEditorEvents(editor, &event);
		}

		SDL_RenderClear(g_renderer);

		DrawMap(map, g_renderer);

		DrawEditor(editor, g_renderer);

		SDL_RenderPresent(g_renderer);
	}

	DestroyMap(map);
	DestroyTextureList(textures);
	DestroyEditor(editor);
	DestroyMod(mod);

	Cleanup(g_window, g_renderer);

	return 0;
}
Exemplo n.º 3
0
void JBoundsEditor::Render()
{
    //  update editors
    int i = 0;
    while (i < m_Edited.size() )
    {
        JBoundsEditContext& ctx = m_Edited[i];
        if (ctx.m_pEdited == NULL)
        {
            //  edited object was destroyed
            JString path = ctx.m_Path;
            RemoveEditor( path.c_str() );
            //  try to find it by path (it's possible, that it was reloaded)
            JObject* pObj = g_pObjectServer->FindObject( path.c_str() );
            if (pObj)
            {
                CreateEditor( pObj );
            }
            continue;
        }

        if (ctx.m_pEditor == NULL)
        {
            //  editor was destroyed
            GetEditorsGroup()->RemoveChild( ctx.m_pEditor );
            m_Edited.erase( m_Edited.begin() + i );
            continue;
        }
        else
        {
            //  hide/show editor according to edited object's visibility
            ctx.m_pEditor->SetVisible( ctx.m_pEdited->IsPathVisible() );
        }
        i++;
    }
} // JBoundsEditor::Render