mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-22 10:12:20 +00:00
Пропущены файлы
This commit is contained in:
parent
78a9887143
commit
a091fe8177
82
mta-mono/src/CMonoFunctions.cpp
Normal file
82
mta-mono/src/CMonoFunctions.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
#include "CResource.h"
|
||||
#include "CResourceManager.h"
|
||||
|
||||
extern ILuaModuleManager10 *g_pModuleManager;
|
||||
extern CResourceManager *g_pResourceManager;
|
||||
|
||||
#define RESOURCE g_pResourceManager->GetFromList( mono_domain_get() )
|
||||
|
||||
void CMonoFunctions::AddInternals( void )
|
||||
{
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Log", CMonoFunctions::Debug::Log );
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Info", CMonoFunctions::Debug::Info );
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error );
|
||||
mono_add_internal_call( "MultiTheftAuto.Native.Config::Get", CMonoFunctions::Config::Get );
|
||||
mono_add_internal_call( "MultiTheftAuto.Native.Config::Set", CMonoFunctions::Config::Set );
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Log( MonoString *string )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Info( MonoString *string )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s\n", mono_string_to_utf8( string ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Error( MonoString *string )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
|
||||
|
||||
g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) );
|
||||
}
|
||||
}
|
||||
|
||||
MonoString *CMonoFunctions::Config::Get( MonoString *msKey )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) );
|
||||
|
||||
return mono_string_new( mono_domain_get(), sValue.c_str() );
|
||||
}
|
||||
|
||||
return mono_string_new( mono_domain_get(), "" );
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
string
|
||||
sKey = mono_string_to_utf8( msKey ),
|
||||
sValue = mono_string_to_utf8( msValue );
|
||||
|
||||
return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), sKey, sValue );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
42
mta-mono/src/CMonoFunctions.h
Normal file
42
mta-mono/src/CMonoFunctions.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
class CMonoFunctions;
|
||||
|
||||
#ifndef __CMONOFUNCTIONS_H
|
||||
#define __CMONOFUNCTIONS_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "lua/CLuaFunctionDefinitions.h"
|
||||
|
||||
class CMonoFunctions
|
||||
{
|
||||
public:
|
||||
static void AddInternals( void );
|
||||
|
||||
class Debug
|
||||
{
|
||||
public:
|
||||
static void Log ( MonoString *string );
|
||||
static void Info ( MonoString *string );
|
||||
static void Error ( MonoString *string );
|
||||
};
|
||||
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
static MonoString *Get ( MonoString *msKey );
|
||||
static bool Set ( MonoString *msKey, MonoString *msValue );
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user