Esempio n. 1
0
extern "C" void QERPlug_Dispatch(const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
	if(!strcmp(p, "Create/Update WAD keypair"))
		UpdateWadKeyPair();
	else if(!strcmp(p, "About..."))
		g_FuncTable.m_pfnMessageBox((GtkWidget*)NULL, PLUGIN_ABOUT, "About", eMB_OK);
}
Esempio n. 2
0
extern "C" void WINAPI QERPlug_Dispatch( LPCSTR p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
	LoadLists();

	if ( !g_bBSPInitDone ) {
		g_BSPTable.m_nSize = sizeof( _QERAppBSPFrontendTable );
		if ( g_FuncTable.m_pfnRequestInterface( QERAppBSPFrontendTable_GUID, static_cast<LPVOID>( &g_BSPTable ) ) ) {
			g_bBSPInitDone = TRUE;
		}
		else
		{
			Sys_ERROR( "_QERAppBSPFrontendTable interface request failed\n" );
			return;
		}
	}

	if ( !strcmp( p, "About..." ) ) {
		DoMessageBox( PLUGIN_ABOUT, "About", IDOK );
	}
	else if ( !strcmp( p, "Colour Changer..." ) ) {
		DoCTFColourChanger();
	}
	else if ( !strcmp( p, "Swap Light Colours" ) ) {
		DoSwapLights();
	}
	else if ( !strcmp( p, "Change Angles 180" ) ) {
		DoChangeAngles();
	}
	else if ( !strcmp( p, "Swap Spawn Points" ) ) {
		DoSwapSpawns();
	}
}
Esempio n. 3
0
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
	if (!strcmp(p, CMD_ABOUT)) {
		g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
	} else {
		Sys_Printf("Message: %s\n", p);
	}
}
void Textool_Cancel(){
	if ( !g_bPatch ) {
		// tell Radiant to update (will also send update windows messages )
		g_SelectedFaceTable.m_pfnSetFaceInfo( 0, &g_CancelFaceData );
	}
	else
	{
		*g_pPatch = g_CancelPatch;
		g_pPatch->bDirty = true;
		g_FuncTable.m_pfnSysUpdateWindows( W_CAMERA );
	}
	// do not call destroy, decref it
	g_pToolWnd->DecRef();
	g_pToolWnd = NULL;
}
void Textool_Validate(){
	// validate current situation into the main view
	g_pManager->Commit();
	// for a brush face we have an aditionnal step
	if ( !g_bPatch ) {
		// tell Radiant to update (will also send update windows messages )
		g_SelectedFaceTable.m_pfnSetFaceInfo( 0, &g_SelectedFaceData );
	}
	else
	{
		// ask to rebuild the patch display data
		g_pPatch->bDirty = true;
		// send a repaint to the camera window as well
		g_FuncTable.m_pfnSysUpdateWindows( W_CAMERA );
	}
	// we'll need to update after that as well:
	g_bTexViewReady = false;
	// send a repaint message
	g_pToolWnd->Redraw();
}
Esempio n. 6
0
extern "C" void QERPlug_Dispatch(const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
  #if 0
  // if it's the first call, perhaps we need some additional init steps
  if (!g_bQglInitDone)
  {
    g_QglTable.m_nSize = sizeof(_QERQglTable);
    if ( g_FuncTable.m_pfnRequestInterface( QERQglTable_GUID, static_cast<LPVOID>(&g_QglTable) ) )
    {
      g_bQglInitDone = true;
    }
    else
    {
      Sys_Printf("TexTool plugin: _QERQglTable interface request failed\n");
      return;
    }
  }

  if (!g_bSelectedFaceInitDone)
  {
    g_SelectedFaceTable.m_nSize = sizeof(_QERSelectedFaceTable);
    if (g_FuncTable.m_pfnRequestInterface (QERSelectedFaceTable_GUID,
					   static_cast<LPVOID>(&g_SelectedFaceTable)))
    {
      g_bSelectedFaceInitDone = true;
    }
    else
    {
      Sys_Printf("TexTool plugin: _QERSelectedFaceTable interface request failed\n");
      return;
    }
  }

  if (!g_bSurfaceTableInitDone)
  {
    g_SurfaceTable.m_nSize = sizeof(_QERAppSurfaceTable);
    if ( g_FuncTable.m_pfnRequestInterface( QERAppSurfaceTable_GUID, static_cast<LPVOID>(&g_SurfaceTable) ) )
    {
      g_bSurfaceTableInitDone = true;
    }
    else
    {
      Sys_Printf("TexTool plugin: _QERAppSurfaceTable interface request failed\n");
      return;
    }
  }

  if (!g_bUITable)
  {
    g_UITable.m_nSize = sizeof(_QERUITable);
    if ( g_FuncTable.m_pfnRequestInterface( QERUI_GUID, static_cast<LPVOID>(&g_UITable) ) )
    {
      g_bUITable = true;
    }
    else
    {
      Sys_Printf("TexTool plugin: _QERUITable interface request failed\n");
      return;
    }
  }
  #endif

  if (!strcmp(p, "About..."))
  {
    DoMessageBox (PLUGIN_ABOUT, "About ...", MB_OK );
  }
  else if (!strcmp(p, "Go..."))
  {
    if (!g_pToolWnd)
    {
      g_pToolWnd = g_UITable.m_pfnCreateGLWindow();
      g_pToolWnd->setSizeParm(300,300);
      g_pToolWnd->setName("TexTool");
      // g_Listener is a static class, we need to bump the refCount to avoid premature release problems
      g_Listen.IncRef();
      // setListener will incRef on the listener too
      g_pToolWnd->setListener(&g_Listen);
      if (!g_pToolWnd->Show())
      {
        DoMessageBox ("Error creating texture tools window!", "TexTool plugin", MB_ICONERROR | MB_OK);
        return;
      }
    }
    
    g_bTexViewReady = false;
    g_bClosing = false;
  }
  else if (!strcmp(p, "Help..."))
  {
    if (!g_bHelp)
      DoMessageBox ("Select a brush face (ctrl+shift+left mouse) or a patch, and hit Go...\n"
		    "See tutorials for more", "TexTool plugin", MB_OK );
    else
      DoMessageBox ("Are you kidding me ?", "TexTool plugin", MB_OK );
    g_bHelp = true;
  }
}
Esempio n. 7
0
void UpdateWadKeyPair( void )
{
  int i,nb;

  char wads[2048]; // change to CString usage ?
  wads[0] = 0;
  char *p1,*p2;
  entity_t *pEntity;
  epair_t *pEpair;
  GSList *wadlist = NULL;
  face_t  *f;
  brush_t *b;
  char cleanwadname[QER_MAX_NAMELEN];
  const char *actualwad;


  pEntity = (entity_t *)g_FuncTable.m_pfnGetEntityHandle(0); // get the worldspawn ent

  Sys_Printf("Searching for in-use wad files...\n");
  for(pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next)
  {
    if (stricmp(pEpair->key,"wad") == 0)
    {
      strcpy(wads,pEpair->value);
      ConvertDOSToUnixName(wads,wads);

      // ok, we got the list of ; delimited wads, now split it into a GSList that contains
      // just the wad names themselves.

      p1 = wads;

      do
      {
        p2 = strchr(p1,';');
        if (p2)
          *p2 = 0; // swap the ; with a null terminator

        if (strchr(p1,'/') || strchr(p1,'\\'))
        {
          ExtractFileName(p1,cleanwadname);
          wadlist = AddToWadList (wadlist, NULL, cleanwadname);
        }
        else
        {
          wadlist = AddToWadList (wadlist, NULL, p1);
        }
        if (p2)
          p1 = p2+1; // point back to the remainder of the string
        else
          p1 = NULL; // make it so we exit the loop.

      } while (p1);

      // ok, now we have a list of wads in GSList.
      // now we need to add any new wadfiles (with their paths) to this list
      // so scan all brushes and see what wads are in use
      // FIXME: scan brushes only in the region ?

      break; // we don't need to process any more key/pairs.
    }
  }

  nb = g_FuncTable.m_pfnAllocateActiveBrushHandles();
  for( i = 0; i < nb; i++ )
	{
    b = (brush_t *)g_FuncTable.m_pfnGetActiveBrushHandle(i);
    if (b->patchBrush) // patches in halflife ?
    {
      wadlist = AddToWadList(wadlist, b->pPatch->pShader->getName(),NULL);
    } else
    {
      for (f=b->brush_faces ; f ; f=f->next)
      {
        wadlist = AddToWadList(wadlist, f->pShader->getName(),NULL);
      }
    }
  }
  g_FuncTable.m_pfnReleaseActiveBrushHandles();

  nb = g_FuncTable.m_pfnAllocateSelectedBrushHandles();
  for( i = 0; i < nb; i++ )
	{
    b = (brush_t *)g_FuncTable.m_pfnGetSelectedBrushHandle(i);
    if (b->patchBrush) // patches in halflife ?
    {
      wadlist = AddToWadList(wadlist, b->pPatch->pShader->getName(),NULL);
    } else
    {
      for (f=b->brush_faces ; f ; f=f->next)
      {
        wadlist = AddToWadList(wadlist, f->pShader->getName(),NULL);
      }
    }
  }
  g_FuncTable.m_pfnReleaseSelectedBrushHandles();

  // Now we have a complete list of wadnames (without paths) so we just have to turn this
  // back to a ; delimited list.

  wads[0] = 0;
  while (wadlist)
  {
    if (stricmp((char *)wadlist->data,"common-hydra.wad") == 0)
    {
      Sys_Printf("Skipping radiant-supplied wad file %s\n",(char *)wadlist->data);
    }
    else
    {
      if (wads[0])
        strcat(wads,";");

      actualwad = vfsGetFullPath((char *)wadlist->data);

      if (actualwad)
      {
        strcat(wads, actualwad);
      }
      else
      {
        Sys_Printf("WARNING: could not locate wad file %s\n",(char *)wadlist->data);
        strcat(wads, (char *)wadlist->data);
      }
    }

    free (wadlist->data);
    wadlist = g_slist_remove (wadlist, wadlist->data);
  }

  // store the wad list back in the worldspawn.
  if (wads[0])
  {
    //free(pEpair->value);
    //pEpair->value = strdup(wads);
    SetKeyValue(pEntity, "wad", wads);
  }

}
Esempio n. 8
0
extern "C" void QERPlug_Dispatch( const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
	Sys_Printf( MSG_PREFIX "Command \"%s\"\n",p );

	if ( !strcmp( p,Q3R_CMD_ABOUT ) ) {
		DoAboutDlg( GTK_WIDGET( g_pMainWidget ) );
	}
	else if ( !strcmp( p,Q3R_CMD_LOAD ) ) {
		CheckInterfaces();

		if ( interfaces_started ) {
			if ( DoLoadPortalFileDialog( GTK_WIDGET( g_pMainWidget ) ) == IDOK ) {
				portals.Load();
				g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
			}
			else
			{
				Sys_Printf( MSG_PREFIX "Portal file load aborted.\n", portals.fn );
			}
		}
	}
	else if ( !strcmp( p,Q3R_CMD_RELEASE ) ) {
		portals.Purge();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}

		Sys_Printf( MSG_PREFIX "Portals unloaded.\n" );
	}
	else if ( !strcmp( p,Q3R_CMD_SHOW_2D ) ) {
		portals.show_2d = !portals.show_2d;

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}
		SaveConfig();

		if ( portals.show_2d ) {
			Sys_Printf( MSG_PREFIX "Portals will be rendered in 2D view.\n" );
		}
		else{
			Sys_Printf( MSG_PREFIX "Portals will NOT be rendered in 2D view.\n" );
		}
	}
	else if ( !strcmp( p,Q3R_CMD_SHOW_3D ) ) {
		portals.show_3d = !portals.show_3d;
		SaveConfig();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}

		if ( portals.show_3d ) {
			Sys_Printf( MSG_PREFIX "Portals will be rendered in 3D view.\n" );
		}
		else{
			Sys_Printf( MSG_PREFIX "Portals will NOT be rendered in 3D view.\n" );
		}
	}
	else if ( !strcmp( p,Q3R_CMD_OPTIONS ) ) {
		DoConfigDialog( GTK_WIDGET( g_pMainWidget ) );
		SaveConfig();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}
	}
}
Esempio n. 9
0
void LoadImage (const char *filename, unsigned char **pic, int *width, int *height)
{
    png_byte** row_pointers;
    unsigned char *fbuffer = NULL;
    png_bytep p_fbuffer;

    int nLen = g_FileSystemTable.m_pfnLoadFile( (char *)filename, (void **)&fbuffer, 0 );
    if (nLen == -1)
        return;

    p_fbuffer = fbuffer;

    // the reading glue
    // http://www.libpng.org/pub/png/libpng-manual.html

    png_structp png_ptr = png_create_read_struct
                          (PNG_LIBPNG_VER_STRING, png_voidp_NULL,
                           user_error_fn, user_warning_fn);
    if (!png_ptr)
    {
        g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_read_struct\n");
        return;
    }

    png_infop info_ptr = png_create_info_struct(png_ptr);
    if (!info_ptr) {
        png_destroy_read_struct(&png_ptr,
                                png_infopp_NULL, png_infopp_NULL);
        g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_info_struct (info_ptr)\n");
        return;
    }

    png_infop end_info = png_create_info_struct(png_ptr);
    if (!end_info) {
        png_destroy_read_struct(&png_ptr, &info_ptr,
                                png_infopp_NULL);
        g_FuncTable.m_pfnSysPrintf ("libpng error: png_create_info_struct (end_info)\n");
        return;
    }

    // configure the read function
    png_set_read_fn(png_ptr, (voidp)&p_fbuffer, (png_rw_ptr)&user_read_data);

    if (setjmp(png_ptr->jmpbuf)) {
        png_destroy_read_struct(&png_ptr, &info_ptr,
                                &end_info);
        if (*pic)
        {
            g_free(*pic);
            free(row_pointers);
        }
        return;
    }

    png_read_info(png_ptr, info_ptr);

    int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
    int color_type = png_get_color_type(png_ptr, info_ptr);

    // we want to treat all images the same way
    //   The following code transforms grayscale images of less than 8 to 8 bits,
    //   changes paletted images to RGB, and adds a full alpha channel if there is
    //   transparency information in a tRNS chunk.
    if (color_type == PNG_COLOR_TYPE_PALETTE)
        png_set_palette_to_rgb(png_ptr);

    if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
        png_set_gray_1_2_4_to_8(png_ptr);

    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
        png_set_tRNS_to_alpha(png_ptr);

    if ( ! ( color_type & PNG_COLOR_MASK_ALPHA ) ) {
        // Set the background color to draw transparent and alpha images over.
        png_color_16 my_background, *image_background;

        if (png_get_bKGD(png_ptr, info_ptr, &image_background))
            png_set_background(png_ptr, image_background,
                               PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
        else
            png_set_background(png_ptr, &my_background,
                               PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);

        // Add alpha byte after each RGB triplet
        png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
    }

    // read the sucker in one chunk
    png_read_update_info(png_ptr, info_ptr);

    color_type = png_get_color_type(png_ptr, info_ptr);
    bit_depth = png_get_bit_depth(png_ptr, info_ptr);

    *width = png_get_image_width(png_ptr, info_ptr);
    *height = png_get_image_height(png_ptr, info_ptr);

    // allocate the pixel buffer, and the row pointers
    int size = (*width)*(*height)*4;
    // still have to use that g_malloc heresy
    *pic = (unsigned char *)g_malloc(size);
    row_pointers = (png_byte**) malloc((*height) * sizeof(png_byte*));

    int i;
    for(i = 0; i < (*height); i++)
        row_pointers[i] = (png_byte*)(*pic) + i * 4 * (*width);

    // actual read
    png_read_image(png_ptr, row_pointers);

    /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
    png_read_end(png_ptr, info_ptr);

    /* free up the memory structure */
    png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);

    free(row_pointers);
    g_FileSystemTable.m_pfnFreeFile (fbuffer);
}
Esempio n. 10
0
void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
{
    g_FuncTable.m_pfnSysPrintf ("libpng error: %s\n", error_msg);
    longjmp(png_ptr->jmpbuf, 0);
}
Esempio n. 11
0
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
{
    g_FuncTable.m_pfnSysPrintf ("libpng warning: %s\n", warning_msg);
}
Esempio n. 12
0
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
	// NOTE: this never happens in a module
  if(!strcmp(p, "About..."))
		g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
}