Example #1
0
	GlobalClipboard::GlobalClipboard(GlobalClipboardOperator* Operator, PluginFileWrapper* PluginWrapper) :
		Operator(nullptr),
		Buffer(nullptr),
		Initialized(false)
	{
		SME_ASSERT(Singleton == nullptr);
		Singleton = this;

		SME_ASSERT(Operator && PluginWrapper);

		this->Operator = Operator;
		this->Buffer = PluginWrapper;
		Initialized = Buffer->Construct(kClipboardBufferPath, true);
	}
Example #2
0
void ActorEquipmentOverrider::ApplyOverride(int BodyPart, ActorBodyModelData * ModelData, TESForm* ModelSource)
{
	if (HandlerTable.size() == 0)
		return;
	else if (GetEnabled() == false)
		return;

	SME_ASSERT(OverrideInProgress == false);
	SME::MiscGunk::ScopedSetter<bool> Sentry(OverrideInProgress, true);

	TESObjectREFR* CurrentRef = ModelData->parentRef;
	SME_ASSERT(CurrentRef && CurrentRef->baseForm && CurrentRef->baseForm->typeID == kFormType_NPC);
	TESNPC* CurrentNPC = OBLIVION_CAST(CurrentRef->baseForm, TESForm, TESNPC);
	TESBipedModelForm* CurrentBiped = OBLIVION_CAST(ModelSource, TESForm, TESBipedModelForm);
	SME_ASSERT(CurrentBiped);

	ActorBodyModelData::BodyPartData* CurrentBodyPart = NULL;
	if (BodyPart == -1
		|| (((CurrentBiped->partMask & (1 << ActorBodyModelData::kBodyPart_LeftRing)) == false)				// need to check for rings additionally as TESNPC::InitWorn passes those as the partID
		&& ((CurrentBiped->partMask & (1 << ActorBodyModelData::kBodyPart_RightRing)) == false)))
	{
		// pick the first part in the part mask, like the engine does
		UInt32 PartID = ActorBodyModelData::kBodyPart_Head;
		while ((PartID == ActorBodyModelData::kBodyPart_Hair &&	(CurrentBiped->partMask & (1 << ActorBodyModelData::kBodyPart_Head)) == true)
			   || (CurrentBiped->partMask & (1 << PartID)) == false)
		{
			PartID++;
			if (PartID >= ActorBodyModelData::kBodyPart__MAX)
			{
				// the biped item has no slots, so bugger off
				return;
			}
		}

		BodyPart = PartID;
	}

	SME_ASSERT(BodyPart >= ActorBodyModelData::kBodyPart_Head && BodyPart < ActorBodyModelData::kBodyPart__MAX);
	CurrentBodyPart = &ModelData->bodyParts[BodyPart];

	_MESSAGE("Attempting to override equipment model for NPC Ref %s (%08X) | Body Part = %d, Source Item = %s (%08X)",
			 InstanceAbstraction::GetFormName(CurrentNPC), CurrentRef->refID, BodyPart, InstanceAbstraction::GetFormName(ModelSource), ModelSource->refID);
	gLog.Indent();

	OverrideHandler::OverrideResultListT Overrides;
	for each (auto Itr in HandlerTable)
	{
		OverrideHandler& ThisHandler = Itr.second;
		ThisHandler.HandleEquipment(ModelData, ModelSource, CurrentRef, CurrentNPC, Overrides);
	}
		bool FormUndoStackOperator::PreUndoRedoCallback( bgsee::FormUndoProxy* Proxy, bgsee::FormUndoProxy** OutAltProxy )
		{
			SME_ASSERT(Proxy && OutAltProxy);

			bool Result = false;

			FormUndoProxy* Current = dynamic_cast<FormUndoProxy*>(Proxy);
			SME_ASSERT(Current);

			*OutAltProxy = new FormUndoProxy(Current->Parent);
			Result = true;

			return Result;
		}
		BasicFormChangeEntry::BasicFormChangeEntry( UInt8 ChangeType, TESForm* Form, UInt32 Value ) :
			ChangeEntry()
		{
			SME_ASSERT(Form);

			char FormatBuffer[0x512] = {0};

			FORMAT_STR(FormatBuffer, "%s\t[%08X]\t%s\t", Form->GetTypeIDString(), Form->formID, Form->editorID.c_str());
			Buffer = FormatBuffer;

			switch (ChangeType)
			{
			case kFormChange_SetActive:
				FORMAT_STR(FormatBuffer, "Modified: %d", Value);
				break;
			case kFormChange_SetDeleted:
				FORMAT_STR(FormatBuffer, "Deleted: %d", Value);
				break;
			case kFormChange_SetFormID:
				FORMAT_STR(FormatBuffer, "FormID: %08X", Value);
				break;
			case kFormChange_SetEditorID:
				FORMAT_STR(FormatBuffer, "EditorID: %s", (const char*)Value);
				break;
			}

			Buffer += FormatBuffer;
		}
		MouseOverPopupProvider::PopupData::PopupData(const char* Name,
													 RenderDelegateT DrawButton, RenderDelegateT DrawPopup,
													 UInt8 PositionType, ImVec2& Pos) :
			PopupName(Name),
			ButtonHoverState(false),
			PopupState(),
			DrawButton(DrawButton),
			DrawPopup(DrawPopup),
			Position(Pos),
			PositionType(PositionType)
		{
			SME_ASSERT(Name && DrawButton && DrawPopup);

			if (PositionType == kPosition_Absolute)
				SME_ASSERT(Pos.x > -1 && Pos.y > -1);
		}
		void MouseOverPopupProvider::Update()
		{
			if (ModalWindowProviderOSDLayer::Instance.HasOpenModals())
				return;
			else if (PreventActivePopupTicking)
			{
				PreventActivePopupTicking = false;
				return;
			}

			if (ActivePopup != kInvalidID && ActivePopupTimeout != 0.f && CloseActivePopup == false)
			{
				SME_ASSERT(ActivePopup < RegisteredPopups.size());

				OSDLayerStateData& ActiveState = RegisteredPopups.at(ActivePopup).PopupState;
				if (ActiveState.DragInput.Active == false)
				{
					ActivePopupTimeout -= ImGui::GetIO().DeltaTime;
					if (ActivePopupTimeout <= 0.f)
					{
						CloseActivePopup = true;
						ActivePopupTimeout = 0.f;
					}
				}
			}
		}
		void BGSEEConsoleCmd_Crash_ExecuteHandler(BGSEECONSOLECMD_ARGS)
		{
			SME::StringHelpers::Tokenizer ArgParser(Args, " ,");
			std::string CurrentArg;

			bool Assertion = false;

			for (int i = 1; i <= ParamCount; i++)
			{
				ArgParser.NextToken(CurrentArg);
				switch (i)
				{
				case 1:
					Assertion = CurrentArg != "0";
					break;
				}
			}

			if (Assertion)
			{
				SME_ASSERT(1 == 0);
			}
			else
			{
				*((int*)0) = 0;
			}
		}
Example #8
0
  void OprtCastToStr::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int /*a_iArgc*/)
  {
	  CodaScriptBackingStore* Store = a_pArg[0]->GetStore();
	  SME_ASSERT(Store);
	  char Buffer[0x512] = {0};

	  switch(Store->GetType())
	  {
	  case ICodaScriptDataStore::kDataType_Numeric:
		  sprintf_s(Buffer, sizeof(Buffer), "%0.6f", Store->GetNumber());
		  *ret = string_type(Buffer);
		  break;
	  case ICodaScriptDataStore::kDataType_Reference:
		  sprintf_s(Buffer, sizeof(Buffer), "%08X", Store->GetFormID());
		  *ret = string_type(Buffer);
		  break;
	  case ICodaScriptDataStore::kDataType_String:
		  *ret = string_type(Store->GetString());
		  break;
	  default:
		  {
			  ErrorContext err;
			  err.Errc = ecINVALID_TYPECAST;
			  err.Type1 =Store->GetType();
			  err.Type2 = ICodaScriptDataStore::kDataType_String;
			  throw ParserError(err);
		  }
	  }
  }
Example #9
0
UInt32 ActorAnimationOverrider::GetSpecialAnims( TESNPC* NPC, const char* Tag, AnimationFileListT& OutFiles ) const
{
	SME_ASSERT(NPC && Tag);

	std::string SkeletonPath = (NPC->model.nifPath.m_data ? NPC->model.nifPath.m_data : "");
	int Count = 0;

	if (SkeletonPath.size())
	{
		SkeletonPath.erase(SkeletonPath.rfind("\\"));
		OutFiles.clear();

		std::string SourceDir = "Data\\Meshes\\" + SkeletonPath + "\\SpecialAnims\\";;
		std::string SearchFilter = "*" + kOverrideFileTag + std::string(Tag) + ".kf";

		for (IDirectoryIterator Itr(SourceDir.c_str(), SearchFilter.c_str()); Itr.Done() == false; Itr.Next())
		{
#ifndef NDEBUG
	//		_MESSAGE("Override Found - %s", Itr.Get()->cFileName);
#endif // !NDEBUG

			OutFiles.push_back(Itr.Get()->cFileName);
			Count++;
		}
	}

	return Count;
}
		TypedEventSource::TypedEventSource(UInt32 TypeID) :
			IEventSource(),
			TypeID(TypeID)
		{
			SME_ASSERT(TypeID > kType__BEGIN && TypeID < kType__END);
			Register(this);
		}
Example #11
0
  void OprtTypeID::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int /*a_iArgc*/)
  {
	  CodaScriptBackingStore* Store = a_pArg[0]->GetStore();
	  SME_ASSERT(Store);

	  *ret = (float_type)Store->GetType();
  }
		void Initialize()
		{
			static BGSEditorExtender::BGSEEWorkspaceManager::DefaultDirectoryListT kDefaultDirectories;
			if (kDefaultDirectories.size() == 0)
			{
				kDefaultDirectories.push_back("Data\\");
				kDefaultDirectories.push_back("Data\\Meshes\\");
				kDefaultDirectories.push_back("Data\\Textures\\");
				kDefaultDirectories.push_back("Data\\Textures\\menus\\");
				kDefaultDirectories.push_back("Data\\Textures\\menus\\icons\\");
				kDefaultDirectories.push_back("Data\\Sound\\");
				kDefaultDirectories.push_back("Data\\Sound\\fx\\");
				kDefaultDirectories.push_back("Data\\Sound\\Voice\\");
				kDefaultDirectories.push_back("Data\\Trees\\");
				kDefaultDirectories.push_back("Data\\Backup\\");

				kDefaultDirectories.push_back(BGSEditorExtender::BGSEEResourceLocation::kBasePath);
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_CODADEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_CODABGDEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_SEDEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_SEPREPROCDEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_SEPREPROCSTDDEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_SESNIPPETDEPOT)()));
				kDefaultDirectories.push_back((BGSEditorExtender::BGSEEResourceLocation(CSE_SEAUTORECDEPOT)()));
			}

			bool ComponentInitialized = BGSEEWORKSPACE->Initialize(BGSEEMAIN->GetAPPPath(),
				new CSEWorkspaceManagerOperator(),
				kDefaultDirectories);
			SME_ASSERT(ComponentInitialized);

			_FILEFINDER->AddSearchPath((std::string(std::string(BGSEEWORKSPACE->GetCurrentWorkspace()) + "Data")).c_str());
		}
Example #13
0
void ActorAnimationOverrider::ApplyOverrides( TESNPC* NPC, AnimationFileListT& Files ) const
{
	SME_ASSERT(NPC);

	TESAnimation* AnimData = &NPC->animation;
	for (AnimationFileListT::iterator Itr = Files.begin(); Itr != Files.end(); Itr++)
	{
		AnimationVisitor Visitor(&AnimData->data);
		char* Path = const_cast<char*>(Itr->c_str());

		if (!Visitor.FindString(Path))
		{
			UInt32 Len = strlen(Path);
			TESAnimation::AnimationNode* NewNode = (TESAnimation::AnimationNode*)FormHeap_Allocate(sizeof(TESAnimation::AnimationNode));
			NewNode->animationName = (char*)FormHeap_Allocate(Len + 1);
			strcpy_s(NewNode->animationName, Len + 1, Path);
			NewNode->next = NULL;

			Visitor.Append(NewNode);

#ifndef NDEBUG
			_MESSAGE("Override Enabled - %s", Path);
#endif // !NDEBUG
		}
	}
}
		bgsee::FormCollectionSerializer* GlobalClipboardOperator::GetSerializer(bgsee::FormListT& Forms)
		{
			bool ExpectedRefs = false;
			SME_ASSERT(Forms.size());

			TESForm* Wrapped = dynamic_cast<TESFormWrapper*>(Forms.at(0))->GetWrappedForm();
			if (Wrapped->IsReference())
				ExpectedRefs = true;

			bgsee::FormCollectionSerializer* Out = DefaultFormSerializer;
			if (ExpectedRefs)
				Out = ObjectRefSerializer;

			for (auto Itr : Forms)
			{
				TESForm* Wrapped = dynamic_cast<TESFormWrapper*>(Itr)->GetWrappedForm();
				if ((Wrapped->IsReference() && ExpectedRefs == false) ||
					(Wrapped->IsReference() == false && ExpectedRefs))
				{
					BGSEECONSOLE_MESSAGE("Selection type mismatch! Selection can be either base forms of the same type or object references");
					Out = nullptr;
				}
			}

			return Out;
		}
Example #15
0
void ActorAnimationOverrider::ClearOverrides( TESNPC* NPC ) const
{
	SME_ASSERT(NPC);

	TESAnimation* AnimData = &NPC->animation;
	if (AnimData->data.animationName || AnimData->data.next)
	{
		std::vector<const char*> Delinquents;
		for (TESAnimation::AnimationNode* Itr = &AnimData->data; Itr && Itr->Info(); Itr = Itr->Next())
		{
			std::string File(Itr->Info()), Comparand(kOverrideFileTag);

			SME::StringHelpers::MakeLower(File);
			SME::StringHelpers::MakeLower(Comparand);

			if (File.find(Comparand) != std::string::npos)
			{
				// our override animation, queue it for removal
				Delinquents.push_back(Itr->Info());
			}
		}

		for (std::vector<const char*>::iterator Itr = Delinquents.begin(); Itr != Delinquents.end(); Itr++)
		{
#ifndef NDEBUG
			_MESSAGE("Override Disabled - %s", *Itr);
#endif // !NDEBUG

			AnimationVisitor Visitor(&AnimData->data);
			Visitor.RemoveString(*Itr);
		}
	}
}
Example #16
0
	ResourceLocation& ResourceLocation::operator=( std::string rhs )
	{
		this->RelativePath = rhs;
		SME_ASSERT(CheckPath() == true);

		return *this;
	}
Example #17
0
void ActorAnimationOverrider::AddToBlacklist( TESNPC* NPC )
{
	SME_ASSERT(NPC);

	if (std::find(Blacklist.begin(), Blacklist.end(), NPC->refID) == Blacklist.end())
		Blacklist.push_back(NPC->refID);
}
				CellViewDialogEventData::CellViewDialogEventData(const CellViewDialogEventSource* Source, TESObjectCELL* Cell, UInt32 Type) :
					IEventData(Source),
					Cell(Cell),
					EventType(Type)
				{
					SME_ASSERT(Cell);
				}
Example #19
0
		ICodaScriptExecutableCode::~ICodaScriptExecutableCode()
		{
			GIC--;
			SME_ASSERT(GIC >= 0);

			SAFEDELETE(ByteCode);
		}
Example #20
0
void ActorAnimationOverrider::RemoveFromBlacklist( TESNPC* NPC )
{
	SME_ASSERT(NPC);

	NPCListT::const_iterator Match = std::find(Blacklist.begin(), Blacklist.end(), NPC->refID);
	if (Match != Blacklist.end())
		Blacklist.erase(Match);
}
		void RenderWindowOSD::DetachLayer(IRenderWindowOSDLayer* Layer)
		{
			SME_ASSERT(Layer);

			LayerArrayT::iterator Match = std::find(AttachedLayers.begin(), AttachedLayers.end(), Layer);
			if (Match != AttachedLayers.end())
				AttachedLayers.erase(Match);
		}
		void ModalWindowProviderOSDLayer::ShowModal(const char* Name, ModalRenderDelegateT Delegate, void* UserData,
													ImGuiWindowFlags Flags, const ImVec2& Size, ImGuiCond SizeCond)
		{
			SME_ASSERT(Name && Delegate);
			SME_ASSERT(*TESRenderWindow::ActiveCell);		// ### modal doesn't show up when called when the scenegraph is empty

			// flag the current open modal, if any, as closed
			if (OpenModals.size())
			{
				ModalData& Top = OpenModals.top();
				if (Top.Open)
					Top.Open = false;
			}

			ModalData NewModal(Name, Delegate, UserData, Flags, Size, SizeCond);
			OpenModals.push(NewModal);
		}
		void GlobalClipboardOperator::DisplayClipboardContents(bgsee::PluginFileWrapper* File)
		{
			TESFileWrapper* Wrapper = dynamic_cast<TESFileWrapper*>(File);

			SME_ASSERT(Wrapper && Wrapper->GetWrappedPlugin());

			TESFileFormListWindow::Show(nullptr, Wrapper->GetWrappedPlugin());
		}
		void CSEHallOfFameFemaleNPC::Initialize( UInt32 FormID )
		{
			CSEHallOfFameEntry::Initialize(FormID);

			TESNPC* NPC = CS_CAST(Instance, TESForm, TESNPC);
			SME_ASSERT(NPC);

			SME::MiscGunk::ToggleFlag(&NPC->actorFlags, TESActorBaseData::kNPCFlag_Female, true);
		}
		void CSEHallOfFameStaff::Initialize( UInt32 FormID )
		{
			CSEHallOfFameEntry::Initialize(FormID);

			TESObjectWEAP* Weapon = CS_CAST(Instance, TESForm, TESObjectWEAP);
			SME_ASSERT(Weapon);

			Weapon->weaponType = TESObjectWEAP::kWeaponType_Staff;
		}
Example #26
0
	WorkspaceManager::WorkspaceManager(const char* DefaultDirectory, WorkspaceManagerOperator* Operator, DefaultDirectoryArrayT& DefaultDirectoryData)
	{
		SME_ASSERT(Singleton == nullptr);
		Singleton = this;

		SME_ASSERT(DefaultDirectory && Operator && DefaultDirectoryData.size() > 1);

		this->DefaultDirectory = DefaultDirectory;
		this->CurrentDirectory = DefaultDirectory;
		this->Operator = Operator;

		for (DefaultDirectoryArrayT::iterator Itr = DefaultDirectoryData.begin(); Itr != DefaultDirectoryData.end(); Itr++)
			DefaultDirectories.push_back(*Itr);

		CreateDefaultDirectories(DefaultDirectory);

		Initialized = true;
	}
		void RenderWindowOSD::AttachLayer(IRenderWindowOSDLayer* Layer)
		{
			SME_ASSERT(Layer);

			if (std::find(AttachedLayers.begin(), AttachedLayers.end(), Layer) != AttachedLayers.end())
				BGSEECONSOLE_MESSAGE("Attempting to re-add the same OSD layer");
			else
				AttachedLayers.push_back(Layer);
		}
Example #28
0
bool ArchiveManager::ExtractArchiveFile( const char* InPath, const char* OutPath, bool AppendFilePath /*= false*/ )
{
	bool Result = false;

	if (InPath)
	{
		std::string Path(InPath); 
		SME::StringHelpers::MakeLower(Path);

		if (Path.find("data\\") != -1)
			Path = Path.substr(Path.find("data\\") + 5);

		if (_FILEFINDER->FindFile(Path.c_str()) == 2)
		{
			ArchiveFile* ArchiveFileStream = CS_CAST(_FILEFINDER->GetFileStream(Path.c_str(), false, 0x50000), NiBinaryStream, ArchiveFile);
			if (ArchiveFileStream)
			{
				UInt32 FileSize = ArchiveFileStream->GetFileSize();
				std::string ArchiveFilePath = ArchiveFileStream->fileName;
				std::string ArchiveFileName = ArchiveFilePath.substr(ArchiveFilePath.rfind("\\") + 1);
				std::string FileOut = OutPath;

				if (AppendFilePath)
					FileOut += "\\" + ArchiveFilePath;

				DeleteFile(FileOut.c_str());		// delete file as BSFile::Ctor doesn't create it anew

				BSFile* TempFile = BSFile::CreateInstance(FileOut.c_str(), NiFile::kFileMode_WriteOnly, FileSize);
				SME_ASSERT(TempFile);

				void* Buffer = FormHeap_Allocate(FileSize);
				ZeroMemory(Buffer, FileSize);

				if (!ArchiveFileStream->DirectRead(Buffer, FileSize))
				{
					BGSEECONSOLE_MESSAGE("ArchiveManager::ExtractArchiveFile - Couldn't read file %s from archive %s", ArchiveFileStream->fileName, ArchiveFileStream->parentArchive->fileName);
				}
				else
				{
					if (!TempFile->DirectWrite(Buffer, FileSize))
					{
						BGSEECONSOLE_MESSAGE("ArchiveManager::ExtractArchiveFile - Couldn't write to file %s", TempFile->fileName);
					}
					else
						Result = true;
				}

				TempFile->Flush();
				TempFile->DeleteInstance();
				ArchiveFileStream->DeleteInstance();
				FormHeap_Free(Buffer);
			}
		}
	}

	return Result;
}
Example #29
0
		ICodaScriptSyntaxTreeEvaluator::ICodaScriptSyntaxTreeEvaluator(ICodaScriptVirtualMachine* VM,
																	   ICodaScriptExpressionParser* Parser,
																	   ICodaScriptProgram* Program) :
			VM(VM),
			Parser(Parser),
			Program(Program),
			Context(nullptr)
		{
			SME_ASSERT(VM && Parser && Program);
		}
Example #30
0
		ICodaScriptSyntaxTreeEvaluator::ICodaScriptSyntaxTreeEvaluator(ICodaScriptVirtualMachine* VM,
																	   ICodaScriptExpressionParser* Parser,
																	   ICodaScriptExecutionContext* Context) :
			VM(VM),
			Parser(Parser),
			Program(nullptr),
			Context(Context)
		{
			SME_ASSERT(VM && Parser && Context);
			Program = Context->GetProgram();
		}