void SetDBParam(const char *db, const char *key, const char *value) { DBProviderType type = GetTypeFromName(db); if (type == INVALID_PROVIDER) return; if (!StrCaseCmp(key, "database")) providers[type].database = g_strdup(value); else if (!StrCaseCmp(key, "username")) providers[type].username = g_strdup(value); else if (!StrCaseCmp(key, "password")) providers[type].password = g_strdup(value); }
// Initialise runtime bool CRuntime::Initialise(CRuntimeSetup* crSetup) { // Start by getting and saving the CPU capabilities. DWORD cpuFeatures = GetCPUCaps(); supportMMX = cpuFeatures & CPU_FEATURE_MMX; supportSSE = cpuFeatures & CPU_FEATURE_SSE; supportSSE2 = cpuFeatures & CPU_FEATURE_SSE2; // Construct requires MMX for collisions #ifndef APPRUNTIME if (!supportMMX) throw runtime_error("Your CPU does not support MMX technology (it must be pretty old!). Please buy a newer PC then try again!"); #endif // Save hInstance hInstance = crSetup->hInstance; CapReader.pRuntime = this; CreateTempDirectory(); // Get app properties BYTE* pData; int dataSize; HGLOBAL hData = OpenResourceBinary(997, "APPBLOCK", pData, dataSize); CapReader.ReadAppProperties(pData, dataSize, props); FreeResource(hData); // Cannot use both multisampling and motion blur #ifndef APPRUNTIME if (multisamples > 0 && motionBlur) throw runtime_error("Cannot enable both multisamples and motion blur. Please change one of these settings."); #endif #ifdef PYTHON // Get python hData = OpenResourceBinary(992, "PYTHONLIBS", pData, dataSize); CapReader.ReadPythonResources(pData, dataSize); FreeResource(hData); if(!SearchPath(NULL, "python26.dll", NULL, 0, NULL, NULL)) throw runtime_error("Python26.dll was not found and is required to run this application or feature. Reinstalling the application " "may fix this problem."); Py_Initialize(); #endif // Get menu resources hData = OpenResourceBinary(993, "MENUBLOCK", pData, dataSize); CapReader.ReadMenuResources(pData, dataSize, menus); FreeResource(hData); crSetup->winWidth = props.winWidth; crSetup->winHeight = props.winHeight; crSetup->eyeDistance = props.eyeDistance; crSetup->screensaver = props.screensaver; fpsMode = props.fpsMode; userFps = props.fps; //if (disableWindowsKey) // g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, DisableWinKeyKeyboardProc, hInstance, 0); #ifdef CONSTRUCT_DIRECTX9 crSetup->display_params.fps_mode = props.fpsMode; crSetup->display_params.fullscreen = fullscreen = props.fullscreen; crSetup->display_params.backbuffer_width = props.winWidth; crSetup->display_params.backbuffer_height = props.winHeight; switch (multisamples) { case 0: // Off crSetup->display_params.multisamples = 0; break; case 1: // 2x crSetup->display_params.multisamples = 2; break; case 2: // 4x crSetup->display_params.multisamples = 4; break; case 3: // 8x crSetup->display_params.multisamples = 8; break; default: crSetup->display_params.multisamples = 0; break; } // PreInit gets the D3D caps and allows MakeWindows to create the correct number of windows to pass to Init() //Display.SetMultiMonitorMode(MMM_CLONE); //Display.PreInit(); renderer.LoadD3D(); #endif #ifndef CONSTRUCT_SDL // Create a window for the runtime if (!MakeWindows(crSetup)) throw runtime_error("Cannot create window"); #else if (SDL_Init(SDL_INIT_VIDEO) < 0) exit(1); // Register SDL_Quit to be called at exit; makes sure things are cleaned up when we quit. atexit(SDL_Quit); // Attempt to create window with 32bit pixels in hardware Display.screen = SDL_SetVideoMode(props.winWidth, props.winHeight, 32, SDL_HWSURFACE); SDL_SetAlpha(Display.screen, SDL_SRCALPHA, 255); // Set alpha to normal #endif InitCommonControls(); // The preview runtimes show the runtime in the title bar. #ifdef CONSTRUCT_PREVIEW #ifdef CONSTRUCT_DIRECTX9 props.appTitle += " (DX9 runtime)"; #endif #ifdef APPRUNTIME props.appTitle += " (App runtime)"; #endif #ifdef CONSTRUCT_SDL props.appTitle += " (SDL runtime)"; #endif #endif #ifndef CONSTRUCT_SDL SetWindowText(hWnds.front(), props.appTitle); #else SDL_WM_SetCaption(props.appTitle, NULL); #endif // Restore mouse cursor from hourglass if (!props.screensaver) SetCursor(LoadCursor(NULL, IDC_ARROW)); // Load a menu if (props.UseMenu) if (menus.size() != 0) SetMenu(hWnds.front(), menus[0]); #ifndef APPRUNTIME #ifndef CONSTRUCT_SDL // Direct-X setup crSetup->display_params.hWnds = hWnds; crSetup->display_params.hFocusWnd = hWnds.front(); winWidthOffset = 0; winHeightOffset = 0; // Retrieve all display modes: can't set an invalid display mode size if (crSetup->display_params.fullscreen) { BOOL bRetVal; DEVMODE devMode; int iMode = 0; int wantedWidth = crSetup->display_params.backbuffer_width; int wantedHeight = crSetup->display_params.backbuffer_height; int bestWidth = 100000; int bestHeight = 100000; bool found = false; do { bRetVal = ::EnumDisplaySettings(NULL, iMode, &devMode); iMode++; if (bRetVal) { int curWidth = devMode.dmPelsWidth; int curHeight = devMode.dmPelsHeight; // Display mode found! if (curWidth == wantedWidth && curHeight == wantedHeight) found = true; // This display mode is big enough to fit the display in, but is smaller than the last best size if ((curWidth >= wantedWidth && curHeight >= wantedHeight) && (curWidth < bestWidth && curHeight < bestHeight)) { bestWidth = curWidth; bestHeight = curHeight; } } } while (bRetVal); // Identical display mode not found: use next best that can fit it all on if (!found) { // Still 100000x100000: no resolution found that supports this if (bestWidth == 100000 || bestHeight == 100000) throw runtime_error("The display resolution required by this application is not supported."); #ifdef CONSTRUCT_PREVIEW CString msg; msg.Format("Switching to Fullscreen mode: Display mode %d x %d not supported, switching to next best %d x %d.\n\n" "The 'Window Width' and 'Window Height' values in Application Properties define the fullscreen resolution.", crSetup->display_params.backbuffer_width, crSetup->display_params.backbuffer_height, bestWidth, bestHeight); MessageBox(NULL, msg, "Fullscreen preview", MB_OK | MB_ICONEXCLAMATION); #endif crSetup->display_params.backbuffer_width = wantedWidth = bestWidth; crSetup->display_params.backbuffer_height = wantedHeight = bestHeight; } } // Set the eye distance before we initialize eyeDistance = crSetup->eyeDistance; renderer.SetEyeDistance(eyeDistance); // Start up the display engine //Display.Init(&(crSetup->d3dDisplaySetup)); renderer.CreateDevice(crSetup->display_params); /* // No identical match for display mode if (crSetup->d3dDisplaySetup.resWidth != actualDisplayWidth || crSetup->d3dDisplaySetup.resHeight != actualDisplayHeight) if (tempDisplayTarget == unallocated_texture) tempDisplayTarget = CreateDisplayTargetTexture(); winWidthOffset = (actualDisplayWidth - crSetup->d3dDisplaySetup.resWidth) / 2; winHeightOffset = (actualDisplayHeight - crSetup->d3dDisplaySetup.resHeight) / 2; } */ GetSwapChains(); // Multi-monitor settings require the temp display target if (renderer.GetMultiMonitorMode() != cr::multimonitor_singlescreen) { if (tempDisplayTarget == unallocated_texture) tempDisplayTarget = CreateDisplayTargetTexture(); } // Linear resizers if (props.sampler == 0) { renderer.SetSamplerState(cr::ss_magfilter, cr::ssv_point); renderer.SetSamplerState(cr::ss_minfilter, cr::ssv_point); } if (props.sampler == 1) { renderer.SetSamplerState(cr::ss_magfilter, cr::ssv_linear); renderer.SetSamplerState(cr::ss_minfilter, cr::ssv_linear); } // Premultiplied alpha mode renderer.SetAlphaBlending(); // Runtime uses clamp-sampling renderer.SetSamplerState(cr::ss_addressu, cr::ssv_clamp); renderer.SetSamplerState(cr::ss_addressv, cr::ssv_clamp); // Create the multisampling target if one required //if (multisamples > 0) // 0 is off // multisampleTargets[0] = renderer.CreateRenderTargetTexture(crSetup->winWidth, crSetup->winHeight, cr::texture_format_a8r8g8b8, true); #if defined(CONSTRUCT_DIRECTX9) && defined(CONSTRUCT_PREVIEW) // Handle shader simulation if (simShader != SS_NOSIM) { UINT ps_major = D3DSHADER_VERSION_MAJOR(renderer.GetCaps().PixelShaderVersion); UINT ps_minor = D3DSHADER_VERSION_MINOR(renderer.GetCaps().PixelShaderVersion); CString hardwarePS; hardwarePS.Format("%d.%d", ps_major, ps_minor); CString simulatedPS; switch (simShader) { case SS_PS14: simulatedPS = "1.4"; break; case SS_PS11: simulatedPS = "1.1"; break; case SS_PS00: simulatedPS = "0.0"; break; } float ps_version = atof(hardwarePS); float sim_version = atof(simulatedPS); // If fullscreen MessageBox()'s won't work if (!fullscreen) { if (sim_version > ps_version) { CString msg; msg.Format("You have chosen to simulate a pixel shader version (PS %s) higher than your hardware supports (PS %s). " "You can only simulate lower hardware capabilities. The application will continue to use PS %s.", simulatedPS, hardwarePS, simulatedPS); MessageBox(NULL, msg, "Simulate shader", MB_OK | MB_ICONEXCLAMATION); } else if (sim_version == ps_version) { CString msg; msg.Format("You have chosen to simulate the same pixel shader version as your hardware supports (PS %s). " "The application will continue normally.", hardwarePS); MessageBox(NULL, msg, "Simulate shader", MB_OK | MB_ICONINFORMATION); } else { CString msg; msg.Format("You are simulating pixel shader %s capabilites. Your hardware supports pixel shader %s.", simulatedPS, hardwarePS); MessageBox(NULL, msg, "Simulate shader", MB_OK | MB_ICONEXCLAMATION); } } } #endif // shader sims #endif // Load the PNG image list hData = OpenResourceBinary(995, "IMAGEBLOCK", pData, dataSize); CapReader.ReadImageData(pData, dataSize, imagehandle_to_address); FreeResource(hData); #ifdef CONSTRUCT_DIRECTX9 // Initialise DirectInput if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&dinput, NULL))) throw runtime_error("Failed to initialise DirectInput. Please ensure you have DirectX 8 or above installed!"); // Initialize the keyboard if (FAILED(dinput->CreateDevice(GUID_SysKeyboard, &d_keyboard, NULL))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_keyboard->SetDataFormat(&c_dfDIKeyboard))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_keyboard->SetCooperativeLevel(hWnds.front(), DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_keyboard->Acquire())) throw runtime_error("Failed to initialise DirectInput."); // initialize the mouse if (FAILED(dinput->CreateDevice(GUID_SysMouse, &d_mouse, NULL))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_mouse->SetCooperativeLevel(hWnds.front(), DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_mouse->SetDataFormat(&c_dfDIMouse))) throw runtime_error("Failed to initialise DirectInput."); if (FAILED(d_mouse->Acquire())) throw runtime_error("Failed to initialise DirectInput."); inputState.isDirectInput = true; #endif #endif //#ifndef APPRUNTIME // Save window dimensions winWidth = crSetup->winWidth; winHeight = crSetup->winHeight; RECT clientSize; GetClientRect(hWnds.front(), &clientSize); realWinWidth = clientSize.right - clientSize.left; realWinHeight = clientSize.bottom - clientSize.top; // Unpack dependencies before loading plugins UnpackDependencies(); // Unpack the resource plugins to the temp dir and load them UnpackPlugins(1000); // Read the frame data hData = OpenResourceBinary(998, "LEVELBLOCK", pData, dataSize); CapReader.ReadFrameData(pData, dataSize); FreeResource(hData); // Map object type names to their pointers for (vector<CRunObjType*>::iterator i = objects.begin(); i != objects.end(); i++) { CString lowername = (*i)->Name; lowername.MakeLower(); name_to_object[lowername] = *i; } #ifdef CONSTRUCT_DEBUGGER // Create debugger once object types are known but before parsing event block (which may send logs) // Create invisible initially pDebug->Create(); pDebug->ShowWindow(SW_HIDE); #endif // Read the CAP event tree hData = OpenResourceBinary(999, "EVENTBLOCK", pData, dataSize); CapReader.ReadEventList(pData, dataSize); FreeResource(hData); // Iterate all events determining their modifiers vector<CRunLayout*>::iterator f = Frames.begin(); const vector<CRunLayout*>::const_iterator Frames_end = Frames.end(); for ( ; f != Frames_end; f++) { EventIterator e = (*f)->Events.begin(); EventConstIterator Events_end = (*f)->Events.end(); for ( ; e != Events_end; ++e) { // Recurse down tree finding SOL modifiers (*e)->GetSolModifiers(*f); // If this event line is a group, it can be marked as top level for optimisation if ((*e)->GetType() == EVENT_GROUP) ((CEventGroup*)*e)->isTopLevel = true; } } // Initialise effects #ifdef CONSTRUCT_DIRECTX9 hData = OpenResourceBinary(994, "HLSL", pData, dataSize); CapReader.ReadHLSLData(pData, dataSize); FreeResource(hData); // If motionblur is required, set up the textures if (motionBlur) { InitMotionBlur(); } #endif //APPRUNTIME // Clock offset (timers relative to Run()) clockOffset = clock(); curFrame = 0; // Mark objects which are not to serialize CRunObjType* pNoSerialize = GetTypeFromName("No serialize"); if (pNoSerialize) { if (!pNoSerialize->teams.empty()) { ObjTypeIterator t = pNoSerialize->teams.begin(); ObjTypeIterator end = pNoSerialize->teams.end(); for ( ; t != end; t++) (*t)->noSerialize = true; } } // Set current frame CRunLayout* pFirstFrame = Frames.front(); runningFrames.push_back(pFirstFrame); system.pLayout = pFirstFrame; pFirstFrame->systemDrawn = true; pFirstFrame->Load(); // Load any other layouts which want their textures loaded on startup vector<CRunLayout*>::iterator ly = Frames.begin(); ly++; // already loaded 1st layout for ( ; ly != Frames.end(); ++ly) { if ((*ly)->texture_loading == CRunLayout::tl_load_on_app_start) (*ly)->LoadLayoutTextures(); else if ((*ly)->texture_loading == CRunLayout::tl_use_app_setting && texture_loading == tl_load_on_app_start) (*ly)->LoadLayoutTextures(); } // Directories exist etc. by now. completedInitialisation = true; // Initial frame mouse coord POINT mouse; GetCursorPos(&mouse); if (!fullscreen) ScreenToClient(hWnds.front(), &mouse); pFirstFrame->mouseX = mouse.x; pFirstFrame->mouseY = mouse.y; // Create initial frame objects (generatevent works) pFirstFrame->CreateInitialObjects(); FlushDelayedObjects(); system.changeResWidth = winWidth; system.changeResHeight = winHeight; // Start of Layout triggered only if not previewing another layout if (previewLayout <= 0) GenerateEvent(-1, SYSTEM_STARTOFFRAME, NULL); #ifdef CONSTRUCT_DEBUGGER pDebug->ShowWindow(SW_SHOW); pDebug->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); pDebug->ModifyStyleEx(0, WS_EX_TOPMOST); #endif // Previewing single layout? if (previewLayout > 0) // if == 0, no need to jump anywhere, already on layout 1 system.DoFrameChange(previewLayout, "none", 0); return true; }
VariantType Variant::GetTypeFromName(const String& typeName) { return GetTypeFromName(typeName.CString()); }
void Variant::FromString(const char* type, const char* value) { return FromString(GetTypeFromName(type), value); }
void Variant::FromString(const String& type, const String& value) { return FromString(GetTypeFromName(type), value.CString()); }
void SetDBType(const char *type) { dbProviderType = GetTypeFromName(type); }
void ObjectBarDialog::Refresh(bool layer_changed) { // check for unnecessary refresh if (layer_changed && !show_only_selected_layer) return; // clear all lists objects.DeleteAllItems(); for (int i = 0; i < large_images.GetImageCount(); i++) large_images.Remove(0); for (int i = 0; i < small_images.GetImageCount(); i++) small_images.Remove(0); if(folderfilter > -1 && folderfilter >= application->object_folders.size()) folderfilter = -1; CObj* pObject; CObjType* pObjectType; CStringArray List; // Object list //object folders if (folderfilter == -1) { HBITMAP large_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT); HBITMAP small_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); for (int i=0; i<application->object_folders.size(); ++i) { if(application->object_folders[i].name == "Default") continue; int item = objects.InsertItem(objects.GetItemCount(), application->object_folders[i].name, ImageID); objects.SetItemData(item, (DWORD_PTR)(const char*)"-1"); } } // -1 is Default, -2 is disabled else if(folderfilter != -2 && application->object_folders[folderfilter].name != "Default") { HBITMAP large_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT); HBITMAP small_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); int item = objects.InsertItem(0,"...\\"+application->object_folders[folderfilter].name, ImageID); objects.SetItemData(item, (DWORD_PTR)(const char*)"-1"); } if (layout) { POSITION LayerPos = layout->layers.GetHeadPosition(); // For each layer while(LayerPos) { CLayer* pLayer = layout->layers.GetNext(LayerPos); if (show_only_selected_layer && pLayer != layout->current_layer) continue; if (!show_nonlayout_objects && pLayer->m_layerType == LAYER_NONFRAME) continue; // Loop all objects CObjList Objects; pLayer->GetEveryObject(Objects, layout); POSITION ObjectPos = Objects.GetHeadPosition(); for (int i = 0; i < Objects.GetCount(); i++) { long ID = Objects.GetNext(ObjectPos); layout->objects.Lookup(ID, pObject); if (pObject->GetGlobalID() != -1) { pObjectType = pObject->GetObjectType(application); // Failed/invalid object type, for some reason if(!pObjectType) continue; //folder filtering if(folderfilter ==-1 && pObjectType->GetFolder() != "Default") continue; else if(folderfilter > -1 && pObjectType->GetFolder()!=application->object_folders[folderfilter].name) continue; bool bAdd = true; for (int j = 0; j < List.GetSize(); j++) if (List.GetAt(j) == pObjectType->GetName()) bAdd = false; if (bAdd) { HBITMAP large_image = pObjectType->m_Image.MakeBitmap(); HBITMAP small_image = pObjectType->small_image.MakeBitmap(); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); int Item = objects.InsertItem(objects.GetItemCount(), pObjectType->GetName(), ImageID); objects.SetItemData(Item, (LPARAM)((const char*)pObjectType->GetName())); List.Add(pObjectType->GetName()); } } // Iterate each object } // Iterate each layer } } else { POSITION Pos = application->object_types.GetStartPosition(); CObjType* oT; long nKey = 0; while (Pos != NULL) { application->object_types.GetNextAssoc(Pos, nKey, oT); if(oT && !oT->m_bIsGroupType) { int ImageID = ImageList_Add(large_images.m_hImageList, oT->m_Image.MakeBitmap(), NULL); int Item = objects.InsertItem(objects.GetItemCount(), oT->GetName(), ImageID); objects.SetItemData(Item, (DWORD)((LPCSTR)oT->GetName())); List.Add(oT->GetName()); } } } objects.ShowScrollBar(SB_VERT); // Work out if there's a vertical scrollbar. If there is, we'll resize a bit. int iListCount = objects.GetItemCount(); int iListSize = objects.GetCountPerPage(); if(iListCount < iListSize) { // Disable the arrows on the vertical scrollbar objects.EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH); objects.SetScrollRange(SB_VERT, 0, 2); } else { // Enable the vertical scrollbar objects.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); } if (sorting == ob_sort_az) objects.SortItems(ObjectCompare, (LPARAM)&objects); if (sorting == ob_sort_za) objects.SortItems(ObjectCompareZA, (LPARAM)&objects); // now replace the ids for (int i = 0; i < objects.GetItemCount(); i++) { if((const char*)objects.GetItemData(i) == "-1") { objects.SetItemData(i, -1); continue; } CObjType* type = GetTypeFromName(application, objects.GetItemText(i, 0)); objects.SetItemData(i, type->ObjectIdentifier); } }
void CParamScintilla::OnChar(NMHDR* pNMHDR, LRESULT* pResult,CScintillaWnd& scintWin, CObjTypeMap* objectMap, CParamTooltipCtrl& m_Tooltip, bool& m_ParameterTooltipIsVisible, bool& m_QuotesOpen, CApplication* pApp, bool bInline) { // This function is only for CScintilla... SCNotification *scn = (SCNotification*)pNMHDR; CString text; scintWin.GetWindowText(text); CString theChar = "a"; theChar.SetAt(0, scn->ch); ::SendMessage(scintWin.m_hWnd, SCI_AUTOCSETSEPARATOR, '|', '|'); int carretPosition = scintWin.GetCurrentPosition(); text = text.Left(carretPosition); // everything to the right is irrelavant // Get last char if (scn->ch=='.') { // Get name of object // First we need to get the current char. text = text.Left(scintWin.GetCurrentPosition()); int pos = 0; char finds[] = " ()+-/*{},"; for(int a = 0; a < strlen(finds); a++) pos = max(pos, text.ReverseFind(finds[a])); CString name = text.Right(text.GetLength() - pos); name = name.Left(name.GetLength() - 1); if(pos!=0) name = name.Right(name.GetLength()-1); bool exists = true; { pApp->m_sort.RemoveAll(); CString intel; if (name != "System") { // Display intellisense // Loop m_TypeCheckerressions CObjType* oT; //POSITION pos = objectMap->GetStartPosition(); //long nKey; //while (pos != NULL) vector<CObjType*> objects; pApp->GetObjectTypes(objects); pApp->GetFamilyObjectTypes(objects); vector<CObjType*>::iterator i = objects.begin(); for(; i != objects.end(); i++) { oT = *i; //objectMap->GetNextAssoc(pos, nKey, oT); CString l = oT->GetName(); CString r = name; l.MakeLower(); r.MakeLower(); if (l == r) { // Enum m_TypeCheckerressions for (int i = 0; i < oT->GetTableCount(2); i++) { ACESEntry2* acesEntry = oT->GetACESEntry(2, i); if(acesEntry->aceDisplayText != "") pApp->m_sort.Add(acesEntry->aceDisplayText); } break; } } } else // System { for (int i = 0; i < GetSystemTableCount(2); i++) { ACESEntry2* ACE; GetSystemExpression(i, ACE); pApp->m_sort.Add(ACE->aceDisplayText); } } pApp->m_sort.Sort(); for (int i = 0; i < pApp->m_sort.GetSize(); i++) { intel += pApp->m_sort.GetAt(i); intel += "|"; } intel = intel.Left(intel.GetLength() - 1); if (intel != "") ::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)intel); } } // Add: Check for inline editing, don't handle this if we are. 0.96.2 else if (scn->ch == '(' && !bInline) { if (m_ParameterTooltipIsVisible) { m_Tooltip.ShowWindow(SW_HIDE); m_ParameterTooltipIsVisible = false; } CString m_TypeCheckerressionName, ObjectName; // Get name of m_TypeCheckerression int pos = text.ReverseFind('.'); CString name = text.Right(text.GetLength() - pos - 1); int start = (text.GetLength() - pos) - 1; m_TypeCheckerressionName = name.Left(name.GetLength() - 1); // Get name of object CString object = text.Left(text.GetLength() - start); pos = object.ReverseFind(' '); name = object.Right(object.GetLength() - pos); ObjectName = name.Left(name.GetLength() - 1); ObjectName.Trim(); bool exists = true; bool alsoexists = false; if (ObjectName == "") ObjectName = "System"; if (exists) { vector<CString> setParams; m_Tooltip.FlushMethods(); if (ObjectName != "System") { CObjType* oT; POSITION pos = objectMap->GetStartPosition(); long nKey; while (pos != NULL) { objectMap->GetNextAssoc(pos, nKey, oT); CString l = oT->GetName(); CString r = ObjectName; l.MakeLower(); r.MakeLower(); if (l == r) { // Enum m_TypeCheckerressions for (int i = 0; i < oT->GetTableCount(2); i++) { ACESEntry2* acesEntry = oT->GetACESEntry(2, i); if (acesEntry->aceDisplayText == m_TypeCheckerressionName) { alsoexists = true; for (int x = 0; x < acesEntry->params.size();x++) { CString addParameter; // Check type if (acesEntry->params[x].type == 1) addParameter.Format("%s [number]", acesEntry->params[x].name); if (acesEntry->params[x].type == 2) addParameter.Format("%s [string]", acesEntry->params[x].name); setParams.push_back(addParameter); } } } break; } } } /*else { int numTableEntries = sizeof(SysExpIntellisenseTable) / sizeof(SysExpIntellisenseTable[0]); setParams.resize(0); for (int i = 0; i < numTableEntries; i++) { CString l = m_TypeCheckerressionName; CString r = SysExpIntellisenseTable[i].expname; l.MakeLower(); r.MakeLower(); if (l == r) { alsoexists = true; CString curParam; int paramNum = 0; do { AfxExtractSubString(curParam, SysExpIntellisenseTable[i].params, paramNum, ','); curParam.Trim(); if (curParam != "") setParams.push_back(curParam); paramNum++; } while (curParam != ""); m_Tooltip.AddMethod(m_TypeCheckerressionName, setParams); setParams.resize(0); } } }*/ if (alsoexists && !m_ParameterTooltipIsVisible) { // Get position of caret int currentPosition = scintWin.SendMessage(SCI_GETCURRENTPOS, 0, 0); int caretX = scintWin.SendMessage(SCI_POINTXFROMPOSITION, 0, 0); int caretY = scintWin.SendMessage(SCI_POINTXFROMPOSITION, 0, 0); if (ObjectName != "System") { CString sMethod; m_Tooltip.AddMethod(m_TypeCheckerressionName, setParams); } m_Tooltip.SetCurMethod(0); m_Tooltip.SetCurParam(0); m_Tooltip.ShowTooltip(CPoint(caretX, caretY)); m_ParameterTooltipIsVisible = true; m_QuotesOpen = false; } } } // Increment parameter count else if (scn->ch == ',' && !bInline) { //scintWin.SendMessage(SCI_AUTOCCOMPLETE, 0, 0); if (m_ParameterTooltipIsVisible && !m_QuotesOpen) m_Tooltip.ShowNextParam(); } // Hide parameter tooltip else if (scn->ch == ')' && !bInline) { //scintWin.SendMessage(SCI_AUTOCCOMPLETE, 0, 0); if (m_ParameterTooltipIsVisible) { m_Tooltip.ShowWindow(SW_HIDE); m_ParameterTooltipIsVisible = false; } } // Hide parameter tooltip else if (scn->ch == '"') { if (m_QuotesOpen) m_QuotesOpen = false; else m_QuotesOpen = true; } // Prompt variable names else if (scn->ch == '\'') { // Trim the right two (' chars eg. Sprite(' text = text.Left(text.GetLength() - 2); CString temp = text; temp.MakeReverse(); int index = temp.FindOneOf(" {}()+-*/"); if (index > -1) text = text.Right(index); // Now find if there's a dot to get the object name index = text.Find('.'); if (index > -1) text = text.Left(index); CObjType* pType = GetTypeFromName(pApp, text); if (pType != NULL) { CString varnames; vector<PrivateValue>::iterator i = pType->m_PrivateValues.begin(); vector<PrivateValue>::iterator end = pType->m_PrivateValues.end(); for ( ; i != end; i++) varnames += i->name + "|"; varnames = varnames.Left(varnames.GetLength() - 1); if (varnames != "") ::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)varnames); } else{ if(text == "global") { CString varnames; list<CApplication::GlobalVariable>::iterator i = pApp->global_variables.begin(); list<CApplication::GlobalVariable>::iterator end = pApp->global_variables.end(); for ( ; i != end; i++) varnames += i->name + "|"; varnames = varnames.Left(varnames.GetLength() - 1); if (varnames != "") ::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)varnames); } } } /*else { if(text.GetLength() == 2) { // Any other type of letter, display intellisense for system expressions and object names CString suggestions; int numTableEntries = sizeof(SysExpIntellisenseTable) / sizeof(SysExpIntellisenseTable[0]); for (int i = 0; i < numTableEntries; i++) { CString expression = SysExpIntellisenseTable[i].expname; suggestions += expression + "|"; } suggestions = suggestions.Left(suggestions.GetLength() - 1); if (suggestions != "") ::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)suggestions); } }*/ }
void ProcessEdittimeExpressionInformation(vector<Token>& ttokens, CApplication* pApp, long oid) { // Now process the tokens setting the sub types to find family and object names, and pointing variable names // to their owners. vector<Token>::iterator t = ttokens.begin(); vector<Token>::iterator ttokens_end = ttokens.end(); int index = 0; long lastOidOwner = -1; for ( ; t != ttokens_end; t++, index++) { switch(t->t) { case T_IDENTIFIER: // Identifier is the first token, or not preceded by a dot: looks like an object or family name if (index == 0 || (t - 1)->t != T_DOT) { CString objName = t->str; bool movementIdentifier = false; CString movName; // Look for '[' in identifier: signals a movement identifier eg. Sprite[Movement] int index = t->str.Find('['); // Movement found if (index > -1) { movementIdentifier = true; // Parse the names out of Obj[Mov] movName = objName; objName = objName.Left(index); movName.Delete(0, index+1); movName.Delete(movName.GetLength() - 1); } CObjType* pType = GetTypeFromName(pApp, objName); list<Family>::iterator family = find(pApp->families.begin(), pApp->families.end(), t->str); if (pType) { t->oidOwner = pType->ObjectIdentifier; lastOidOwner = pType->ObjectIdentifier; if (movementIdentifier) { t->tsub = TT_MOVEMENTNAME; t->id = pType->GetBehaviorByName(movName)->id; } else t->tsub = TT_OBJECTNAME; } else if (family != pApp->families.end()) { if(family->is_in_use) { t->tsub = TT_FAMILYNAME; t->oidOwner = family->identifier; lastOidOwner = family->identifier; } } }//identifier break; case T_VARIABLENAME: // Previous token is an open bracket: use the last owner. // Otherwise, for standalone variable names, use the expression owner. bool isStandalone = true; // Looking for pattern <obj name> <open bracket> if (index >= 2) { if ((t - 1)->t == T_LEFTBRACKET && (t - 2)->t == T_IDENTIFIER && ((t - 2)->tsub == TT_OBJECTNAME || (t - 2)->tsub == TT_FAMILYNAME)) { isStandalone = false; } CString n = (t - 2)->str; n.MakeLower(); // Look for a global variable name if ((t - 1)->t == T_LEFTBRACKET && (t - 2)->t == T_IDENTIFIER && n == "global") { t->oidOwner = -1; // now work out the id for(list<CApplication::GlobalVariable>::iterator i = pApp->global_variables.begin(); i!= pApp->global_variables.end(); i++) { CString l = i->name; CString r = t->str; l.MakeLower(); r.MakeLower(); if(l == r) t->id = i->identifier; } break; } } // Looking for pattern <dot> <identifier> <open bracket> var name <close bracket/comma> // eg .Value(...) if (index >= 3) { if ((t - 1)->t == T_LEFTBRACKET && (t - 2)->t == T_IDENTIFIER && (t - 3)->t == T_DOT) { if (t + 1 != ttokens_end && ((t + 1)->t == T_RIGHTBRACKET || (t + 1)->t == T_COMMA)) isStandalone = false; } } // Use action/condition OID for standalones if (isStandalone) t->oidOwner = oid; // Use last OID for object variables eg. Sprite('Rofl') else t->oidOwner = lastOidOwner; // now work out the id CObjType* pType = pApp->FindObjTypeFromNumber(t->oidOwner); if(pType) { for(vector<PrivateValue>::iterator i = pType->m_PrivateValues.begin(); i!= pType->m_PrivateValues.end(); i++) { CString l = i->name; CString r = t->str; l.MakeLower(); r.MakeLower(); if(l == r) { t->id = i->identifier; break; } } } break; } } }