Jump to content
  • 0

Hiding a specific object


נσναnz
Go to solution Solved by VegaS™,

Question

2 answers to this question

Recommended Posts

  • 1
  • Moderator
  • Solution

I'm sure that you saw my graphic mask from some years ago.

Here you can hide the 'terrain''object''cloud''water''tree', and you can disable the effects and more too if you take a look inside of GameLib.

That feature class allows you to hide specific effects, tree, bulding by property crc or name (not done yet).

 

You''ll need also:

I'll not make a full how-to right now, just take a look, implement the class, call it and do some changes as you want, you've more than the basic idea. ?

  • graphic_mask/building.txt
general_obj_stone14
ob-b1-005-woodbarrel
landmark_statuestone
B_general_obj_40
general_obj_jar_yellow01
  • graphic_mask/effect.txt
8182371290
1003918098
volcano_greatsmoke.mse
warpgate01
fall_7
fire_general_obj_charcoal.mse

 

GameLib/Area.cpp

 

Hidden Content

    Give reaction to this post to see the hidden content.

UserInterface/PythonGraphicMask.cpp

Spoiler
/*********************************************************************
* title_name		: Test Graphic Mask
* date_created		: 2018.04.21
* filename			: PythonGraphicMask.cpp
* author			: VegaS
* version_actual	: Version 0.1
*/

#include "stdafx.h"
#if defined(ENABLE_GRAPHIC_MASK)
#include "PythonGraphicMask.h"
#include "PythonSystem.h"
#include "../GameLib/MapOutdoor.h"
#include "../GameLib/MapType.h"

CPythonGraphicMask::CPythonGraphicMask()
{
	Initialize(PROPERTY_TYPE_NONE, "graphic_mask/default.txt");
	Initialize(PROPERTY_TYPE_TREE, "graphic_mask/tree.txt");
	Initialize(PROPERTY_TYPE_BUILDING, "graphic_mask/building.txt");
	Initialize(PROPERTY_TYPE_EFFECT, "graphic_mask/effect.txt");
}

CPythonGraphicMask::~CPythonGraphicMask()
{
	Destroy();
}

void CPythonGraphicMask::Initialize(const BYTE bPropertyType, const char * c_pszFileName)
{
	m_vecMaskObjectCRC[bPropertyType].clear();
	
	if (bPropertyType == PROPERTY_TYPE_NONE)
		return;

	auto* fp = fopen(c_pszFileName, "r");
	if (!fp)
	{
		Tracef("Can't open file %s.", c_pszFileName);
		return;
	}

	char line[256];
	while (fgets(line, sizeof(line) - 1, fp))
	{
		const auto& dwCRC = strtoul(line, nullptr, 0);
		m_vecMaskObjectCRC[bPropertyType].push_back(dwCRC);
	}
}

void CPythonGraphicMask::Destroy()
{
	for (auto& i : m_vecMaskObjectCRC)
		i.clear();
}

bool CPythonGraphicMask::IsEnabled(BYTE bPropertyType) const
{
	if (bPropertyType >= PROPERTY_TYPE_MAX_NUM)
		return false;
	
	switch (bPropertyType)
	{
		case prt::PROPERTY_TYPE_TREE:
			bPropertyType = CMapOutdoor::PART_TREE;
			break;
		case prt::PROPERTY_TYPE_BUILDING:
			bPropertyType = CMapOutdoor::PART_OBJECT;
			break;
		case prt::PROPERTY_TYPE_EFFECT:
			bPropertyType = CMapOutdoor::PART_EFFECT;
			break;
		default:
			break;
	}
	
	static auto& rkSystem = CPythonSystem::Instance();
	return rkSystem.GetGraphicMaskPart(bPropertyType);
}

bool CPythonGraphicMask::GetObjectByCRC(const BYTE bPropertyType, const DWORD dwCRC) const
{
	if (bPropertyType >= PROPERTY_TYPE_MAX_NUM)
		return false;

	return std::count(m_vecMaskObjectCRC[bPropertyType].begin(), m_vecMaskObjectCRC[bPropertyType].end(), dwCRC) > 0;
}
#endif

 

UserInterface/PythonGraphicMask.h

Spoiler
#pragma once

class CPythonGraphicMask : public CSingleton<CPythonGraphicMask>
{
	public:
		CPythonGraphicMask();
		virtual ~CPythonGraphicMask();

		enum
		{
			PROPERTY_TYPE_NONE,
			PROPERTY_TYPE_TREE,
			PROPERTY_TYPE_BUILDING,
			PROPERTY_TYPE_EFFECT,
			PROPERTY_TYPE_MAX_NUM,
		};
	
		void		Initialize(const BYTE bPropertyType, const char * c_pszFileName);
		void		Destroy();

		bool		GetObjectByCRC(const BYTE bPropertyType, const DWORD dwCRC) const;
		bool		IsEnabled(BYTE bPropertyType) const;
	protected:
		std::vector<DWORD> m_vecMaskObjectCRC[PROPERTY_TYPE_MAX_NUM];
};

 

UserInterface/PythonSystem.cpp

Spoiler
#if defined(ENABLE_GRAPHIC_MASK)
bool CPythonSystem::GetGraphicMaskPart(const BYTE bPart) const
{
	switch (bPart)
	{
		case CMapOutdoor::PART_TERRAIN:
			return m_Config.bGraphicMaskTerrain;
		case CMapOutdoor::PART_OBJECT:
			return m_Config.bGraphicMaskObject;
		case CMapOutdoor::PART_CLOUD:
			return m_Config.bGraphicMaskCloud;
		case CMapOutdoor::PART_WATER:
			return m_Config.bGraphicMaskWater;
		case CMapOutdoor::PART_TREE:
			return m_Config.bGraphicMaskTree;
		case CMapOutdoor::PART_EFFECT:
			return m_Config.bGraphicMaskEffect;
	}

	return false;
}

void CPythonSystem::SetGraphicMaskPart(const BYTE bPart, const bool bFlag)
{
	switch (bPart)
	{
		case CMapOutdoor::PART_TERRAIN:
			m_Config.bGraphicMaskTerrain = bFlag;
			break;
		case CMapOutdoor::PART_OBJECT:
			m_Config.bGraphicMaskObject = bFlag;
			break;
		case CMapOutdoor::PART_CLOUD:
			m_Config.bGraphicMaskCloud = bFlag;
			break;
		case CMapOutdoor::PART_WATER:
			m_Config.bGraphicMaskWater = bFlag;
			break;
		case CMapOutdoor::PART_TREE:
			m_Config.bGraphicMaskTree = bFlag;
			break;
		case CMapOutdoor::PART_EFFECT:
			m_Config.bGraphicMaskEffect = bFlag;
			break;
	}
}
#endif

 

 

 

 

Edited by VegaS™ (see edit history)
  • Love 3
Link to post
  • 0
On 8/16/2020 at 10:59 PM, VegaS™ said:

I'm sure that you saw my graphic mask from some years ago.

Here you can hide the 'terrain''object''cloud''water''tree', and you can disable the effects and more too if you take a look inside of GameLib.

That feature class allows you to hide specific effects, tree, bulding by property crc or name (not done yet).

 

You''ll need also:

I'll not make a full how-to right now, just take a look, implement the class, call it and do some changes as you want, you've more than the basic idea. ?

  • graphic_mask/building.txt
general_obj_stone14
ob-b1-005-woodbarrel
landmark_statuestone
B_general_obj_40
general_obj_jar_yellow01
  • graphic_mask/effect.txt
8182371290
1003918098
volcano_greatsmoke.mse
warpgate01
fall_7
fire_general_obj_charcoal.mse

 

GameLib/Area.cpp

void CArea::__SetObjectInstance(TObjectInstance * pObjectInstance, const TObjectData * c_pData)
{
	CProperty * pProperty;
	if (!CPropertyManager::Instance().Get(c_pData->dwCRC, &pProperty))
		return;

#if defined(ENABLE_GRAPHIC_MASK)
	const char * c_pszPropertyName;
	if (!pProperty->GetString("PropertyName", &c_pszPropertyName))
		return;
  
	static auto& rkGraphicMask = CPythonGraphicMask::Instance();
	const auto& bPropertyType = prt::GetPropertyType(c_szPropertyType);
	// TODO: pProperty->GetFileName() || c_pszPropertyName
	if (rkGraphicMask.IsEnabled(bPropertyType) && rkGraphicMask.GetObjectByCRC(bPropertyType, c_pData->dwCRC))
		return;
#endif
	[...]

}

UserInterface/PythonGraphicMask.cpp

  Reveal hidden contents

/*********************************************************************
* title_name		: Test Graphic Mask
* date_created		: 2018.04.21
* filename			: PythonGraphicMask.cpp
* author			: VegaS
* version_actual	: Version 0.1
*/

#include "stdafx.h"
#if defined(ENABLE_GRAPHIC_MASK)
#include "PythonGraphicMask.h"
#include "PythonSystem.h"
#include "../GameLib/MapOutdoor.h"
#include "../GameLib/MapType.h"

CPythonGraphicMask::CPythonGraphicMask()
{
	Initialize(PROPERTY_TYPE_NONE, "graphic_mask/default.txt");
	Initialize(PROPERTY_TYPE_TREE, "graphic_mask/tree.txt");
	Initialize(PROPERTY_TYPE_BUILDING, "graphic_mask/building.txt");
	Initialize(PROPERTY_TYPE_EFFECT, "graphic_mask/effect.txt");
}

CPythonGraphicMask::~CPythonGraphicMask()
{
	Destroy();
}

void CPythonGraphicMask::Initialize(const BYTE bPropertyType, const char * c_pszFileName)
{
	m_vecMaskObjectCRC[bPropertyType].clear();
	
	if (bPropertyType == PROPERTY_TYPE_NONE)
		return;

	auto* fp = fopen(c_pszFileName, "r");
	if (!fp)
	{
		Tracef("Can't open file %s.", c_pszFileName);
		return;
	}

	char line[256];
	while (fgets(line, sizeof(line) - 1, fp))
	{
		const auto& dwCRC = strtoul(line, nullptr, 0);
		m_vecMaskObjectCRC[bPropertyType].push_back(dwCRC);
	}
}

void CPythonGraphicMask::Destroy()
{
	for (auto& i : m_vecMaskObjectCRC)
		i.clear();
}

bool CPythonGraphicMask::IsEnabled(BYTE bPropertyType) const
{
	if (bPropertyType >= PROPERTY_TYPE_MAX_NUM)
		return false;
	
	switch (bPropertyType)
	{
		case prt::PROPERTY_TYPE_TREE:
			bPropertyType = CMapOutdoor::PART_TREE;
			break;
		case prt::PROPERTY_TYPE_BUILDING:
			bPropertyType = CMapOutdoor::PART_OBJECT;
			break;
		case prt::PROPERTY_TYPE_EFFECT:
			bPropertyType = CMapOutdoor::PART_EFFECT;
			break;
		default:
			break;
	}
	
	static auto& rkSystem = CPythonSystem::Instance();
	return rkSystem.GetGraphicMaskPart(bPropertyType);
}

bool CPythonGraphicMask::GetObjectByCRC(const BYTE bPropertyType, const DWORD dwCRC) const
{
	if (bPropertyType >= PROPERTY_TYPE_MAX_NUM)
		return false;

	return std::count(m_vecMaskObjectCRC[bPropertyType].begin(), m_vecMaskObjectCRC[bPropertyType].end(), dwCRC) > 0;
}
#endif

 

UserInterface/PythonGraphicMask.h

  Reveal hidden contents

#pragma once

class CPythonGraphicMask : public CSingleton<CPythonGraphicMask>
{
	public:
		CPythonGraphicMask();
		virtual ~CPythonGraphicMask();

		enum
		{
			PROPERTY_TYPE_NONE,
			PROPERTY_TYPE_TREE,
			PROPERTY_TYPE_BUILDING,
			PROPERTY_TYPE_EFFECT,
			PROPERTY_TYPE_MAX_NUM,
		};
	
		void		Initialize(const BYTE bPropertyType, const char * c_pszFileName);
		void		Destroy();

		bool		GetObjectByCRC(const BYTE bPropertyType, const DWORD dwCRC) const;
		bool		IsEnabled(BYTE bPropertyType) const;
	protected:
		std::vector<DWORD> m_vecMaskObjectCRC[PROPERTY_TYPE_MAX_NUM];
};

 

UserInterface/PythonSystem.cpp

  Reveal hidden contents

#if defined(ENABLE_GRAPHIC_MASK)
bool CPythonSystem::GetGraphicMaskPart(const BYTE bPart) const
{
	switch (bPart)
	{
		case CMapOutdoor::PART_TERRAIN:
			return m_Config.bGraphicMaskTerrain;
		case CMapOutdoor::PART_OBJECT:
			return m_Config.bGraphicMaskObject;
		case CMapOutdoor::PART_CLOUD:
			return m_Config.bGraphicMaskCloud;
		case CMapOutdoor::PART_WATER:
			return m_Config.bGraphicMaskWater;
		case CMapOutdoor::PART_TREE:
			return m_Config.bGraphicMaskTree;
		case CMapOutdoor::PART_EFFECT:
			return m_Config.bGraphicMaskEffect;
	}

	return false;
}

void CPythonSystem::SetGraphicMaskPart(const BYTE bPart, const bool bFlag)
{
	switch (bPart)
	{
		case CMapOutdoor::PART_TERRAIN:
			m_Config.bGraphicMaskTerrain = bFlag;
			break;
		case CMapOutdoor::PART_OBJECT:
			m_Config.bGraphicMaskObject = bFlag;
			break;
		case CMapOutdoor::PART_CLOUD:
			m_Config.bGraphicMaskCloud = bFlag;
			break;
		case CMapOutdoor::PART_WATER:
			m_Config.bGraphicMaskWater = bFlag;
			break;
		case CMapOutdoor::PART_TREE:
			m_Config.bGraphicMaskTree = bFlag;
			break;
		case CMapOutdoor::PART_EFFECT:
			m_Config.bGraphicMaskEffect = bFlag;
			break;
	}
}
#endif

 

 

 

 

Thank you man !! It worked

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.