project-navigation
Personal tools

Author Topic: Code upload  (Read 6931 times)

stralep

  • Guest
Code upload
« on: May 14, 2006, 08:20:05 pm »
How coul I give you some code I made? Here it is for now( nothing special, just a litle diferent hover effect in base). I guess that it was better to send diff file... This is from src/client/cl_basemanagement.c
Code: [Select]

/*======================
MN_DrawBase
======================*/
void MN_DrawBase( menuNode_t *node )
{
float x, y;
int mx, my, width, height, row, col, isBuilding, drawBuildingText=0;
static vec4_t color = {1.0, 1.0, 1.0, 0.5};
char image[MAX_QPATH], statusImage[MAX_QPATH];
building_t *entry, *secondEntry,*mousePointed;

if ( ! baseCurrent )
Cbuf_ExecuteText( EXEC_NOW, "mn_pop" );

width = node->size[0] / BASE_SIZE;
height = ( node->size[1] + BASE_SIZE*20 ) / BASE_SIZE;

IN_GetMousePos( &mx, &my );

for ( row = 0; row < BASE_SIZE; row++ )
{
for ( col = 0; col < BASE_SIZE; col++ )
{
// 20 is the height of the part where the images overlap
x = node->pos[0] + col * width;
y = node->pos[1] + row * height - row * 20 ;

// maybe we are out
if ( x < node->pos[0] - width ) continue;
if ( y < node->pos[1] - height) break;
if ( x > node->pos[0] + node->size[0] ) break;
if ( y > node->pos[1] + node->size[1] ) return;

baseCurrent->posX[row][col][baseCurrent->baseLevel] = x;
baseCurrent->posY[row][col][baseCurrent->baseLevel] = y;

if ( baseCurrent->map[row][col][baseCurrent->baseLevel] != -1 )
{
entry = B_GetBuildingByID(baseCurrent->map[row][col][baseCurrent->baseLevel]);
isBuilding=1;

if ( ! entry )
Sys_Error("Error in DrawBase - no building with id %i\n", baseCurrent->map[row][col][baseCurrent->baseLevel] );

if ( entry->buildingStatus[entry->howManyOfThisType] == B_UPGRADE )
Q_strncpyz( statusImage, "base/upgrade", MAX_QPATH );
else if ( entry->buildingStatus[entry->howManyOfThisType] == B_DOWN )
Q_strncpyz( statusImage, "base/down", MAX_QPATH );
else if ( entry->buildingStatus[entry->howManyOfThisType] == B_REPAIRING
|| entry->buildingStatus[entry->howManyOfThisType] == B_MAINTENANCE )
Q_strncpyz( statusImage, "base/repair", MAX_QPATH );
else if ( entry->buildingStatus[entry->howManyOfThisType] == B_UNDER_CONSTRUCTION )
Q_strncpyz( statusImage, "base/construct", MAX_QPATH );

if ( !entry->used )
{
if ( entry->needs )
entry->used = 1;
Q_strncpyz( image, entry->image, MAX_QPATH );
}
else
{
secondEntry = B_GetBuilding ( entry->needs );
if ( ! secondEntry )
Sys_Error( "Error in ufo-scriptfile - could not find the needed building\n" );
Q_strncpyz( image, secondEntry->image, MAX_QPATH );
entry->used = 0;
}
}
else
{
isBuilding=0;
Q_strncpyz( image, "base/grid", MAX_QPATH );
}

if ( mx > x && mx < x + width && my > y && my < y + height - 20 )
{
re.DrawColor( color );
if(isBuilding)
{
mousePointed = entry;
drawBuildingText = 1;
}
}

if ( *image )
re.DrawNormPic( x, y, width, height, 0, 0, 0, 0, 0, qfalse, image );

if ( mx > x && mx < x + width && my > y && my < y + height - 20 )
re.DrawColor( NULL );

if ( *statusImage )
{
// re.DrawNormPic( x + 20 , y + 60, width, height, 0, 0, 0, 0, 0, false, statusImage );
statusImage[0] = '\0';
}
}
}
if(drawBuildingText)
{
VectorSet( color, 0.5f, 1.0f, 0.5f );
color[3] = 1.0f;
re.DrawColor( color );
re.FontLength( "f_small", mousePointed->name, &width, &height );
re.FontDrawString( "f_small", 0, mx, my, width, mousePointed->title);
re.DrawColor( NULL );
}
}

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Code upload
« Reply #1 on: May 14, 2006, 09:46:41 pm »
yes, please send a diff file

if you plan to make more contributions, you can get write access to svn.

all you need is a sourceforge.net account.

stralep

  • Guest
Code upload
« Reply #2 on: May 14, 2006, 10:12:16 pm »
Here's diff file
Code: [Select]

1577c1577
< int mx, my, width, height, row, col;
---
> int mx, my, width, height, row, col, isBuilding, drawBuildingText=0;
1580c1580
< building_t *entry, *secondEntry;
---
> building_t *entry, *secondEntry,*mousePointed;
1609a1610
> isBuilding=1;
1639a1641,1642
> {
> isBuilding=0;
1640a1644
> }
1642c1646,1647
< if ( mx > x && mx < x + width && my > y && my < y + height - 20 )
---
> if ( mx > x && mx < x + width && my > y && my < y + height - 20 )
> {
1643a1649,1654
> if(isBuilding)
> {
> mousePointed = entry;
> drawBuildingText = 1;
> }
> }
1657a1669,1677
> if(drawBuildingText)
> {
> VectorSet( color, 0.5f, 1.0f, 0.5f );
> color[3] = 1.0f;
> re.DrawColor( color );
> //re.FontLength( "f_small", mousePointed->name, &width, &height );
> re.FontDrawString( "f_small", 0, mx+3, my, 10, mousePointed->title);
> re.DrawColor( NULL );
> }
1658a1679
>

This diff has done to file I downloaded few hours ago.
I do plan to do more code, my username on SourceForge is also stralep.
I don't have much expirience in SVN, so I don't know is it good idea...

Hoehrer

  • Guest
Code upload
« Reply #3 on: May 15, 2006, 12:19:58 pm »
Quote from: "stralep"
I do plan to do more code, my username on SourceForge is also stralep.
I don't have much expirience in SVN, so I don't know is it good idea...

No problem, if anything goes wrong you can reset it anytime. That's what SVN is for (beside other reasons) :)
And if you used cvs before you will find svn even easier to use ;)

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Code upload
« Reply #4 on: May 15, 2006, 01:33:02 pm »
you will have write access in a minute

EDIT: sf-user stralep has been added to the project (Subversion Access)