public string GetLocationName(int index) { string locationName = null; QSPWrapper.GetLocationName(index, out locationName); return(locationName); }
private static QSPVariable GetAllValues(string name) { QSPVariable newQSPVariable; var valueCount = QSPWrapper.GetVariableValuesCount(name); var indexCount = QSPWrapper.GetVariableIndexesCount(name); if (valueCount == 0) { int intValue; string strValue; QSPWrapper.GetVariableValues(name, 0, out intValue, out strValue); newQSPVariable = new QSPVariable(name, strValue, intValue); } else { newQSPVariable = new QSPVariable(name, valueCount, indexCount); for (int i = 0; i < valueCount; i++) { int intValue; string strValue; QSPWrapper.GetVariableValues(name, i, out intValue, out strValue); newQSPVariable.AddValue(i, strValue, intValue); } for (int i = 0; i < indexCount; i++) { int valueIndex; string indexName; QSPWrapper.GetIndexNameForVariable(name, i, out valueIndex, out indexName); newQSPVariable.SetIndexName(valueIndex, indexName); } } return(newQSPVariable); }
public bool OpenSavedGame(string savePath, bool isRefreshed) { StopGame(); if (isGameWorldLoaded) { logger.Information($"Loading save: {savePath}"); if (QSPWrapper.QSPLoadSavedGame(savePath, isRefreshed)) { if (isGameWorldActive && savePath == currentSaveFile) { UpdateVariableList(); } else { currentSaveFile = savePath; isGameWorldActive = true; PopulateVariableList(); RefreshActionList(); RefreshObjectList(); } SendPropertyChange(); return(true); } else { return(false); } } else { return(false); } }
public bool LoadGameWorld(string QSPPath) { StopGame(); logger.Information($"Opening game: {QSPPath}"); isGameWorldLoaded = QSPWrapper.QSPOpenGameFile(QSPPath); isGameWorldActive = false; //RestartWorld(true); return(isGameWorldLoaded); }
private void RefreshObjectList() { logger.Information("Refresh Object List"); ObjectList.Clear(); for (int i = 0; i < QSPWrapper.GetObjectsCount(); i++) { string imgPath = null; string desc = null; QSPWrapper.GetObjectData(i, out imgPath, out desc); ObjectList.Add(new QSPObject(i, imgPath, desc)); } }
private void ElapsedEvent(object sender, ElapsedEventArgs e) { try { var result = QSPWrapper.ExecCounter(true); logger.Verbose($"Callback {nameof(ElapsedEvent)} => {result}"); } catch (Exception exp) { logger.Error(exp.ToString()); foreach (var str in lastDebugCommands) { logger.Error(str); } } }
private void PopulateVariableList() { logger.Information("Populate Variable List"); var variablesList = new Dictionary <string, QSPVariable>(); for (int i = 0; i < MaxVariablesCount; i++) { var name = QSPWrapper.GetVariableNameByIndex(i); if (!string.IsNullOrEmpty(name)) { var newVariable = GetAllValues(name); variablesList.Add(newVariable.FullVariableName, newVariable); } } _variableList = variablesList; }
private void Call_RefreshInt(bool isRedrawn) { logger.Verbose($"Callback {nameof(Call_RefreshInt)}: {isRedrawn}"); if (QSPWrapper.QSPIsMainDescChanged()) { logger.Information($"Callback {nameof(Call_RefreshInt)}{isRedrawn}: Main Description changed"); OnPropertyChanged(nameof(MainDescription)); } if (QSPWrapper.IsVarsDescChanged()) { logger.Information($"Callback {nameof(Call_RefreshInt)}{isRedrawn}: Vars Description changed"); OnPropertyChanged(nameof(VarsDescription)); } if (oldRefreshCount != FullRefreshCount) { logger.Information($"Callback {nameof(Call_RefreshInt)}{isRedrawn}: Refresh Count {oldRefreshCount} => {FullRefreshCount}"); oldRefreshCount = FullRefreshCount; OnPropertyChanged(nameof(FullRefreshCount)); } }
public static Exception GetLastError() { QSPWrapper.QSPErrorCode error; int errorActIndex; int errorLine; var ptrError = IntPtr.Zero; QSPWrapper.QSPGetLastErrorData(out error, ref ptrError, out errorActIndex, out errorLine); Exception exception; if (ptrError == IntPtr.Zero) { exception = new Exception(QSPWrapper.GetErrorDesc(error)); } else { var errorStr = Marshal.PtrToStringUni(ptrError); exception = new Exception($"Error #{error} {errorStr} actIndex: {errorActIndex} line:{errorLine}"); } return(exception); }
public QSPGameWorld() { logger = new LoggerConfiguration() .WriteTo.Trace() .CreateLogger(); logger.Information("QSPGameWorld Constructor"); qspWrapper = new QSPWrapper(); QSPWrapper.EnableDebugMode(true); actionList = new BindingList <QSPAction>(); objectList = new BindingList <QSPObject>(); stopWatch = new Stopwatch(); timer = new Timer(); timer.Elapsed += new ElapsedEventHandler(ElapsedEvent); lastDebugCommands = new Queue <string>(10); #region delegates setup var intptr_delegate = IntPtr.Zero; callDebug = new QSP_CALL_DEBUG(Call_Debug); callIsPlayingFile = new QSP_CALL_ISPLAYINGFILE(Call_IsPlayingFile); callPlayFile = new QSP_CALL_PLAYFILE(Call_PlayFile); callCloseFile = new QSP_CALL_CLOSEFILE(Call_CloseFile); callShowImage = new QSP_CALL_SHOWIMAGE(Call_ShowImage); callShowWindow = new QSP_CALL_SHOWWINDOW(Call_ShowWindow); callDeleteMenu = new QSP_CALL_DELETEMENU(Call_DeleteMenu); callAddMenuItem = new QSP_CALL_ADDMENUITEM(Call_AddMenuItem); callShowMenu = new QSP_CALL_SHOWMENU(Call_ShowMenu); callShowMessage = new QSP_CALL_SHOWMSGSTR(Call_ShowMessage); callRefreshInt = new QSP_CALL_REFRESHINT(Call_RefreshInt); callSetTimer = new QSP_CALL_SETTIMER(Call_SetTimer); callSetInputText = new QSP_CALL_SETINPUTSTRTEXT(Call_SetInputText); callSystem = new QSP_CALL_SYSTEM(Call_System); callOpenGameStatus = new QSP_CALL_OPENGAMESTATUS(Call_OpenGameStatus); callSaveGameStatus = new QSP_CALL_SAVEGAMESTATUS(Call_SaveGameStatus); callSleep = new QSP_CALL_SLEEP(Call_Sleep); callGetMSCount = new QSP_CALL_GETMSCOUNT(Call_GetMSCount); callInputBox = new QSP_CALL_INPUTBOX(Call_InputBox); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callDebug); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_DEBUG, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callIsPlayingFile); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_ISPLAYINGFILE, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callPlayFile); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_PLAYFILE, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callCloseFile); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_CLOSEFILE, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callShowImage); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SHOWIMAGE, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callShowWindow); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SHOWWINDOW, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callDeleteMenu); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_DELETEMENU, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callAddMenuItem); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_ADDMENUITEM, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callShowMenu); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SHOWMENU, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callShowMessage); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SHOWMSGSTR, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callRefreshInt); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_REFRESHINT, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callSetTimer); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SETTIMER, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callSetInputText); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SETINPUTSTRTEXT, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callSystem); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SYSTEM, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callOpenGameStatus); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_OPENGAMESTATUS, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callSaveGameStatus); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SAVEGAMESTATUS, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callSleep); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_SLEEP, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callGetMSCount); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_GETMSCOUNT, intptr_delegate); intptr_delegate = Marshal.GetFunctionPointerForDelegate(callInputBox); QSPWrapper.SetCallBack(QSPWrapper.QSPCallback.QSP_CALL_INPUTBOX, intptr_delegate); #endregion delegate setup }
private static bool ExecString(string cmd, bool isRefreshed) { return(QSPWrapper.QSPExecString(cmd, isRefreshed)); }
public bool WriteSaveGame(string savePath, bool isRefreshed) { logger.Information($"Saving game to {savePath}"); return(QSPWrapper.QSPWriteSaveGame(savePath, isRefreshed)); }
public override bool RestartWorld(bool isRefreshed) { return(QSPWrapper.RestartGame(isRefreshed)); }
public override bool ExecCommand(string command) { logger.Information($"Running command : {command}"); return(QSPWrapper.QSPExecString(command, true)); }
public void GetCurrentStateData(out string location, out int actIndex, out int line) { QSPWrapper.GetCurrentStateData(out location, out actIndex, out line); }