Ejemplo n.º 1
0
/*  Function: PointOut
	Creates a pointer for every player pointing to the calling object.

	Parameters:
	color   - Pointer's color modulation.
	message - A message shown above the pointer. */
global func PointOut(int color, string message) {
	for(var count = GetPlayerCount(), i = 0; i < count; i++) {
		var p = GetPlayerByIndex(i);
		CreatePointer(p, this, color, message);
	}
	return count;
}
Ejemplo n.º 2
0
LRESULT CEsmRefCellPage::OnRecordDrop (LPARAM lParam, LPARAM wParam) {
  DEFINE_FUNCTION("CEsmRefCellPage::OnRecordDrop()");
  CEsmCell*	  pCell = (CEsmCell *) m_pRecInfo->pRecord;
  CString	  Buffer;
  CMWEditDoc*     pSourceDoc = (CMWEditDoc *) lParam;
  esmrecinfo_t*   pRecInfo = (esmrecinfo_t *) wParam;
  CEsmSubCellRef* pNewCellRef;
  cellrefdata_t*  pCellRefData;

	/* Ensure we only drag from the current document */
  if (pSourceDoc != GetDocument()) return (0);
  
	/* Only accept certain types */
  if (!IsESMRecordModel(pRecInfo->pRecord->GetType())) return (0);
  //return (0);

	/* Add a new item to the cell */
  CreatePointer(pNewCellRef, CEsmSubCellRef);
  pNewCellRef->CreateNew((CEsmCell *) m_pRecInfo->pRecord);
  pNewCellRef->SetIsActive(true);
  pNewCellRef->SetIndex(pCell->GetNextRefIndex(), 0);
  pNewCellRef->SetRefName(pRecInfo->pRecord->GetID());

  pCellRefData = AddNewCellRef(pNewCellRef);

	/* Update the reference list */
  m_CellRefList.AddItem(pNewCellRef);
  return (0);
 }
Ejemplo n.º 3
0
CEsmFile* CMWEditApp::LoadMaster (const TCHAR* pString, CEsmLoadDlg* pLoadDlg) {
  DEFINE_FUNCTION("CMWEditApp::LoadMaster()");
  CEsmFile* pFile;
  bool	    Result;

	/* Find an existing file */
  pFile = FindMaster(pString);

  if (pFile != NULL) {
    pLoadDlg->SetFilename(pString);
    pLoadDlg->SetProgress(100.0f);
    return (pFile);
   }
  
	/* Create a new file */  
  CreatePointer(pFile, CEsmFile);
  m_EsmMasters.Add(pFile);
  pFile->SetMaster(true);

	/* Progress dialog initialization */
  pLoadDlg->SetFilename(pString);
  pLoadDlg->SetSubLabel(_T("Loading..."));
  pLoadDlg->SetProgress(0.0f);
  pFile->SetCallback(g_EsmLoadDlgCallback, (long) pLoadDlg);

	/* Attempt to read the file */
  Result = pFile->Read(pString);

  if (!Result) {
    ErrorHandler.Notify("Master Read Error!");
   }
   
  return (pFile);

 }
Ejemplo n.º 4
0
void CEsmRefCellPage::OnCellrefCreatecopy() {
  DEFINE_FUNCTION("CEsmRefCellPage::OnCellrefDelete()");
  CEsmCell*	  pCell = (CEsmCell *) m_pRecInfo->pRecord;
  POSITION	  SelPos;
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  cellrefdata_t*  pCellRefData;
  int		  SelectedIndex;
  
	/* Copy all selected records */
  SelPos = m_CellRefList.GetFirstSelectedItemPosition();

  while (SelPos != NULL) {
    SelectedIndex = m_CellRefList.GetNextSelectedItem(SelPos);
    pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(SelectedIndex);
    if (pOldCellRef == NULL) continue;

    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
    pNewCellRef->SetIsActive(true);
    pNewCellRef->SetIndex(pCell->GetNextRefIndex(), 0);
    pCellRefData = AddNewCellRef(pNewCellRef);

	/* Update the reference list */
    m_CellRefList.AddItem(pNewCellRef);
   }

	/* Update the display */
  UpdateCellRefList();
 }
Ejemplo n.º 5
0
cellrefdata_t* CEsmRefCellPage::CleanCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::CleanCellRef()");
  cellrefdata_t* pCellRefData;

	/* See if the record already exists in array */
  pCellRefData = FindNewCellRef(pCellRef);

  if (pCellRefData != NULL) {

		/* Delete a new reference sub-record outright */
    if (pCellRefData->IsNew) {
      m_ModCellRefs.DeleteElement(pCellRefData);
      DestroyPointer(pCellRefData->pNewCellRef);
      DestroyPointer(pCellRefData);
      return (pCellRefData);
     }
    
	/* Update the reference element to clean it */
    pCellRefData->Type = ESMCELLREF_MODTYPE_CLEAN;
    return (pCellRefData);
   }

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = false;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_CLEAN;
  pCellRefData->pNewCellRef = pCellRef;
  pCellRefData->pOldCellRef = pCellRef;

  return (pCellRefData);
 }
Ejemplo n.º 6
0
LRESULT CEsmRefCellPage::OnRecordEdit (LPARAM lParam, LPARAM wParam) {
  DEFINE_FUNCTION("CEsmRefCellPage::OnRecordEdit()");
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  CEsmCellRefDlg  RefDialog;
  cellrefdata_t*  pCellRefData;
  bool		  Result;
  bool		  IsNew;
  bool		  NewAllocated;

	/* Ignore if no record currently selected */
  if (lParam < 0) return (0);
  pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(lParam);
  if (pOldCellRef == NULL) return (0);

	/* See if the reference record is already 'new' */
  pCellRefData = FindNewCellRef(pOldCellRef);

  if (pCellRefData == NULL) {
    if (pOldCellRef->IsDeleted()) return (0);
    IsNew = false;
    NewAllocated = true;
    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
   }
  else {
    if (pOldCellRef->IsDeleted()) return (0);
    if (pCellRefData->Type == ESMCELLREF_MODTYPE_DEL) return (0);
    NewAllocated = false;
    IsNew = pCellRefData->IsNew;
    pNewCellRef = pCellRefData->pNewCellRef;
   }
  
	/* Display the modal edit dialogue */
  Result = RefDialog.DoModal(pNewCellRef, true, (CEsmCell *) m_pRecInfo->pRecord);

  if (!Result) {
    if (NewAllocated) {
      DestroyPointer(pNewCellRef);
     }
    return (0);
   }

	/* Create a new cell ref data record if required */ 
  if (pCellRefData == NULL) {
    pCellRefData = ModifyCellRef(pNewCellRef);
    pCellRefData->pOldCellRef = pOldCellRef;
    pNewCellRef->SetFRMRFlag(1);
   }
  else {
    pCellRefData->Type = ESMCELLREF_MODTYPE_MOD;
   }

	/* Update the display */
  UpdateCellRefList();
  return (0);
 }
Ejemplo n.º 7
0
 *=========================================================================*/
CNifCopyInfo* CNifCopyDlg::AddCopyInfo (void) {
  DEFINE_FUNCTION("CNifCopyDlg::AddCopyInfo()");
  CNifCopyInfo* pNewInfo;

	/* Allocate the new pointer */
  CreatePointer(pNewInfo, CNifCopyInfo);
  m_CopyInfos.Add(pNewInfo);

	/* Initialize the new info */
  pNewInfo->CsvColIndex       = -1;
  pNewInfo->pSourceTexture    = NULL;
  pNewInfo->pMaterialProperty = NULL;

  return (pNewInfo);
 }
Ejemplo n.º 8
0
void CEditUndoStack::CreateEntireText (const TCHAR* pString) {
  DEFINE_FUNCTION("CEditUndoStack::CreateDeleteString()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetString(pString);
  pUndo->SetAction(EDITUNDO_ENTIRETEXT);
  pUndo->SetSelStart(0);
  pUndo->SetSelEnd(0);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Ejemplo n.º 9
0
void CEditUndoStack::CreateDeleteString (const TCHAR* pString, const int StartSel, const int EndSel) {
  DEFINE_FUNCTION("CEditUndoStack::CreateDeleteString()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetString(pString);
  pUndo->SetAction(EDITUNDO_DELETESTRING);
  pUndo->SetSelStart(StartSel);
  pUndo->SetSelEnd(EndSel);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Ejemplo n.º 10
0
void CEditUndoStack::CreateInsertChar (const TCHAR Char, const int StartSel, const int EndSel) {
  DEFINE_FUNCTION("CEditUndoStack::CreateInsertChar()");
  CEditUndo* pUndo;

  CreatePointer(pUndo, CEditUndo);
  m_UndoStack.Add(pUndo);

  pUndo->SetChar(Char);
  pUndo->SetAction(EDITUNDO_INSERTCHAR);
  pUndo->SetSelStart(StartSel);
  pUndo->SetSelEnd(EndSel);

  if (m_UndoStack.GetNumElements() > m_Limit) {
    m_UndoStack.DeleteElement(0);
  }
}
Ejemplo n.º 11
0
cellrefdata_t* CEsmRefCellPage::AddNewCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::CleanCellRef()");
  cellrefdata_t* pCellRefData;

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = true;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_NEW;
  pCellRefData->pOldCellRef = NULL;
  pCellRefData->pNewCellRef = pCellRef;

  return (pCellRefData);
 }
Ejemplo n.º 12
0
cellrefdata_t* CEsmRefCellPage::ModifyCellRef (CEsmSubCellRef* pCellRef) {
  DEFINE_FUNCTION("CEsmRefCellPage::DeleteCellRef()");
  cellrefdata_t* pCellRefData;

	/* See if the record already exists in array */
  pCellRefData = FindNewCellRef(pCellRef);

  if (pCellRefData != NULL) {
    pCellRefData->Type = ESMCELLREF_MODTYPE_MOD;
    return (pCellRefData);
   }

	/* Add a new record to the modified array */
  CreatePointer(pCellRefData, cellrefdata_t);
  m_ModCellRefs.AddElement(pCellRefData);

	/* Initialize the new cell ref data */
  pCellRefData->IsNew = false;
  pCellRefData->Type  = ESMCELLREF_MODTYPE_MOD;
  pCellRefData->pNewCellRef = pCellRef;
  pCellRefData->pOldCellRef = pCellRef;

  return (pCellRefData);
 }
Ejemplo n.º 13
0
 }
/*===========================================================================
 *		End of Class Method CEsmRefCellPage::DeleteCellRef()
 *=========================================================================*/


/*===========================================================================
 *
 * Class CEsmRefCellPage Method - void DeleteIndex (ListIndex, Delete);
 *
 * Deletes or undeletes the given list record.
 *
 *=========================================================================*/
void CEsmRefCellPage::DeleteIndex (const int ListIndex, const bool Delete) {
  DEFINE_FUNCTION("CEsmRefCellPage::DeleteIndex()");
  CEsmSubCellRef* pOldCellRef;
  CEsmSubCellRef* pNewCellRef;
  CEsmCellRefDlg  RefDialog;
  cellrefdata_t*  pCellRefData;
  
	/* Get the given cell reference object */
  pOldCellRef = (CEsmSubCellRef *) m_CellRefList.GetItemData(ListIndex);
  if (pOldCellRef == NULL) return;

	/* See if the reference record is already 'new' */
  pCellRefData = FindNewCellRef(pOldCellRef);

  if (pCellRefData == NULL) {
    CreatePointer(pNewCellRef, CEsmSubCellRef);
    pNewCellRef->Copy(pOldCellRef);
   }
  else {
    pNewCellRef = pCellRefData->pNewCellRef;
   }

	/* Create a new cell ref data record if required */ 
  if (pCellRefData == NULL) {
    pCellRefData = DeleteCellRef(pNewCellRef);
    pCellRefData->pOldCellRef = pOldCellRef;
    pCellRefData->pNewCellRef = pNewCellRef;
   }
  else {
    pCellRefData->Type = ESMCELLREF_MODTYPE_DEL;
   }

	/* Delete or undelete the reference */
  pCellRefData->pNewCellRef->SetDelete(Delete);
  pCellRefData->pNewCellRef->SetFRMRFlag(1);
 }
Ejemplo n.º 14
0
int SDLShell::Run(int argc, char *argv[])
{
	printf("*** %s, V%s ***\n", GetAppName(), GetAppVersion());

	int done;
	Uint8 *keys;

	if (SDL_Init(SDL_INIT_VIDEO))
	{
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 0;
	}

	ProcessCommandLine(argc, argv);

	if (!InitApp())
	{
		Exit(EXIT_INIT_APP);
	}

	SDL_Surface *screen;

	if (Verbose(VerboseAll))
	{
		printf("Setting width = %d, height = %d, bpp = %d\n",
			ShellGet(SDLShell::SHELL_WIDTH),
			ShellGet(SDLShell::SHELL_HEIGHT),
			ShellGet(SDLShell::SHELL_BPP));
	}
	screen = SDL_SetVideoMode(ShellGet(SDLShell::SHELL_WIDTH),
				ShellGet(SDLShell::SHELL_HEIGHT),
				ShellGet(SDLShell::SHELL_BPP), Flags());

	if (!screen)
	{
		fprintf(stderr, "Couldn't set %dx%d GL video mode: %s\n", 
			ShellGet(SDLShell::SHELL_WIDTH),
				ShellGet(SDLShell::SHELL_HEIGHT), SDL_GetError());
		
		Exit(EXIT_NO_SCREEN);
	}
	char tempString[100];
	sprintf(tempString, "%s V%s", GetAppName(), GetAppVersion());
	SDL_WM_SetCaption(tempString, GetAppName());

	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, ShellGet(SHELL_VSYNC));

	if (RequiresOpenGL2())
	{
		// Initialize GLEW and make sure OpenGL 2.0 is supported
		GLenum err = glewInit();
		if(GLEW_OK != err)
		{
		    fprintf(stderr, "[ Fail ] - Error: %s\n", glewGetErrorString(err));
			Exit(EXIT_NO_GL2_SUPPORT);
		}

		if(!GLEW_VERSION_2_0 &&
		   !(GLEW_ARB_shading_language_100 && GLEW_ARB_shader_objects &&
		     GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader))
		{
		    fprintf(stderr, "[ Fail ] - Shaders not supported\n");
			Exit(EXIT_NO_GL2_SUPPORT);
		}

		if(!GLEW_ARB_vertex_buffer_object)
		{
		    fprintf(stderr, "[ Fail ] - VBO objects are not supported\n");
			Exit(EXIT_NO_GL2_SUPPORT);
		}
	}

	if (RequiresTTF())
	{

		if (TTF_Init() == -1) 
		{
			printf("Unable to initialize SDL_ttf: %s \n", TTF_GetError());
			Exit(EXIT_NO_FONT);
		}
	}

	CreatePointer();
	if (!InitGL())
	{
		Exit(EXIT_INIT_GL);
	}

	done = 0;
	while (!done)
	{
		pPointer->Input();
		ResetPressed();
		ResetMouse();

		SDL_Event event;

		while ( SDL_PollEvent(&event) ) 
		{
			switch(event.type)
			{
			case SDL_VIDEORESIZE:
				if (ShellGet(SDLShell::SHELL_RESIZABLE))
				{				
					screen = SDL_SetVideoMode(event.resize.w, event.resize.h,
								ShellGet(SDLShell::SHELL_BPP),
								Flags());
					if (screen)
					{
						Reshape(screen->w, screen->h);
					}
					else
					{
						/* Uh oh, we couldn't set the new video mode?? */;
					}
				}
				break;
            case SDL_MOUSEMOTION:
				pPointer->UpdateMouseMotion(event.motion);
				/*if (Verbose(VerboseAll))
				{
                	printf("Mouse moved by %d,%d to (%d,%d)\n", 
                       event.motion.xrel, event.motion.yrel,
                       event.motion.x, event.motion.y);
				}*/
                break;
            case SDL_MOUSEBUTTONDOWN:
				if (event.button.button == SDL_BUTTON_WHEELDOWN)
				{
					scrollDown = true;
				}
				pPointer->UpdateMouseButton(event.button);
				/*if (Verbose(VerboseAll))
				{
                	printf("Mouse button %d pressed at (%d,%d)\n",
                       event.button.button, event.button.x, event.button.y);
				}*/
                break;
            case SDL_MOUSEBUTTONUP:
				if (event.button.button == SDL_BUTTON_WHEELUP)
				{
					scrollUp = true;
				}
				if (event.button.button == SDL_BUTTON_LEFT)
				{
					leftClick = true;
				}
				if (event.button.button == SDL_BUTTON_RIGHT)
				{
					rightClick = true;
				}
				pPointer->UpdateMouseButton(event.button);
				/*if (Verbose(VerboseAll))
				{
                	printf("Mouse button %d released at (%d,%d)\n",
                       event.button.button, event.button.x, event.button.y);
				}*/
                break;

			case SDL_KEYUP:
				SetPressed(event.key.keysym.scancode, false);
				SetPressing(event.key.keysym.scancode, false);
				break;
			case SDL_KEYDOWN:
				if (Verbose(VerboseInfo))
				{
					printf("Pressed key %d\n", (int)event.key.keysym.scancode);
				}
				if (!KeyPressing(event.key.keysym.scancode))
				{
					SetPressed(event.key.keysym.scancode, true);
				}
				SetPressing(event.key.keysym.scancode, true);
				break;

			case SDL_QUIT:
				done = 1;
				break;
			}
		}
		keys = SDL_GetKeyState(NULL);

		if (keys[SDLK_ESCAPE])
		{
			done = 1;
		}

		if (!Render())
			break;

		SDL_GL_SwapBuffers();

		shellFrame++;
	}
	ReleaseGL();
	ReleaseApp();

	SDL_Quit();
	return 0;             /* ANSI C requires main to return int. */
}