Initial commit
This commit is contained in:
366
application/demos/example.opengl/engine/element.c
Normal file
366
application/demos/example.opengl/engine/element.c
Normal file
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* This file is automaticaly generated, Please dont edit this file!
|
||||
*/
|
||||
#include <engine/element.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void element_constructor( element * this ) {
|
||||
|
||||
vector_char_pointer_add( this->featureNames, "useBackgroundImage" );
|
||||
|
||||
vector_char_pointer_add( this->featureNames, "useBorder" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
vector4 element_colorConverter( element * this, char * hexValue ) {
|
||||
|
||||
int r;
|
||||
|
||||
int g;
|
||||
|
||||
int b;
|
||||
|
||||
int a;
|
||||
|
||||
sscanf( hexValue, "%02x%02x%02x%02x", &r, &g, &b, &a );
|
||||
|
||||
printf("opacity: %i\n");
|
||||
|
||||
struct vector4 rgbColor = vector4_new( r, g, b, (float)a );
|
||||
|
||||
return rgbColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void element_setOriginal( element * this ) {
|
||||
|
||||
this->originalSize = this->size;
|
||||
|
||||
this->originalPosition = this->position;
|
||||
|
||||
this->originalBackgroundColor = this->backgroundColor;
|
||||
|
||||
}
|
||||
|
||||
void element_setter_size( element * this, vector2 a ) {
|
||||
|
||||
this->size.x = a.x;
|
||||
|
||||
this->size.y = a.y;
|
||||
|
||||
printf("set size: %f %f\n", this->size.x, this->size.y);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void element_setter_position( element * this, vector3 a ) {
|
||||
|
||||
this->position.x = a.x;
|
||||
|
||||
this->position.y = a.y;
|
||||
|
||||
this->position.z = a.z;
|
||||
|
||||
printf("set position: %f %f\n", this->position.x, this->position.y);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool element_featureIsEnabled( element * this, int featureValue ) {
|
||||
|
||||
return ( this->features & featureValue ) > 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int element_getFeatureValueByFeatureName( element * this, char * featureName ) {
|
||||
|
||||
int count = vector_char_pointer_length( this->featureNames );
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
char * currentFeatureName = vector_char_pointer_get( this->featureNames, i );
|
||||
|
||||
if( char_operator_compare( featureName , currentFeatureName) ) {
|
||||
|
||||
return powf( 2, i );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int element_updateFeature( element * this ) {
|
||||
|
||||
int currentFeatureValue;
|
||||
|
||||
currentFeatureValue = element_getFeatureValueByFeatureName( this, "useBackgroundImage" );
|
||||
|
||||
if( element_featureIsEnabled( this, currentFeatureValue ) ) {
|
||||
|
||||
if( !this->useBackgroundImage ) {
|
||||
|
||||
this->features -= currentFeatureValue;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if( this->useBackgroundImage ) {
|
||||
|
||||
this->features += currentFeatureValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return this->features;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void element_setter_background( element * this, int count, int datatypes[], ... ) {
|
||||
|
||||
va_list args;
|
||||
|
||||
va_start( args, count );
|
||||
|
||||
int datatype = datatypes[0];
|
||||
|
||||
|
||||
printf("datatype: %i\n\n\n", datatype);
|
||||
|
||||
if( datatype == -2 ) {
|
||||
|
||||
char * message = va_arg( args, char * );
|
||||
|
||||
if( ( char ) message[0] == 35 ) {
|
||||
|
||||
printf("Hex color\n\n\n");
|
||||
|
||||
message++;
|
||||
|
||||
vector4 rgba = element_colorConverter( this, message );
|
||||
|
||||
this->backgroundColor = vector3_new( rgba.x, rgba.y, rgba.z );
|
||||
|
||||
this->opacity = rgba.w / 256;
|
||||
|
||||
this->useBackgroundImage = false;
|
||||
|
||||
} else {
|
||||
|
||||
this->backgroundImagePath = message;
|
||||
|
||||
this->useBackgroundImage = true;
|
||||
|
||||
printf("path\n\n\n");
|
||||
|
||||
}
|
||||
|
||||
printf(" char *: %s\n\n\n ", message);
|
||||
|
||||
}
|
||||
|
||||
if( datatype > 0 ) {
|
||||
|
||||
char * className = getClassName( datatype );
|
||||
|
||||
if( char_operator_compare( className , "vector3") ) {
|
||||
|
||||
vector3 message = va_arg( args, vector3 );
|
||||
|
||||
this->backgroundColor = message;
|
||||
|
||||
this->useBackgroundImage = false;
|
||||
|
||||
}
|
||||
|
||||
if( char_operator_compare( className , "vector4") ) {
|
||||
|
||||
vector4 message = va_arg( args, vector4 );
|
||||
|
||||
this->backgroundColor = vector3_new( message.x, message.y, message.z );
|
||||
|
||||
this->opacity = message.w;
|
||||
|
||||
this->useBackgroundImage = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void element_click( element * this ) {
|
||||
|
||||
|
||||
this->backgroundColor = vector3_new( 0, 256, 256 );
|
||||
|
||||
}
|
||||
|
||||
void element_mousedown( element * this ) {
|
||||
|
||||
|
||||
|
||||
this->backgroundColor = vector3_new( 0, 256, 256 );
|
||||
|
||||
element_setter_position( this, vector3_new( 256, 256, 100 ) );
|
||||
|
||||
}
|
||||
|
||||
void element_mouseup( element * this ) {
|
||||
|
||||
|
||||
|
||||
this->backgroundColor = this->originalBackgroundColor;
|
||||
|
||||
element_setter_position( this, this->originalPosition );
|
||||
|
||||
}
|
||||
|
||||
void element_mouseover( element * this ) {
|
||||
|
||||
this->backgroundColor = vector3_new( 256, 256, 256 );
|
||||
|
||||
}
|
||||
|
||||
void element_mouseleave( element * this ) {
|
||||
|
||||
printf("mouse leave\n");
|
||||
|
||||
this->backgroundColor = this->originalBackgroundColor;
|
||||
|
||||
}
|
||||
|
||||
element element_new() {
|
||||
|
||||
element instance;
|
||||
|
||||
instance.position = vector3_new( 0, 0, 0 );
|
||||
|
||||
instance.size = vector2_new( 0, 0 );
|
||||
|
||||
instance.backgroundColor = vector3_new( 0, 0, 0 );
|
||||
|
||||
instance.originalPosition = vector3_new( 0, 0, 0 );
|
||||
|
||||
instance.originalSize = vector2_new( 0, 0 );
|
||||
|
||||
instance.originalBackgroundColor = vector3_new( 0, 0, 0 );
|
||||
|
||||
instance.opacity = 1;
|
||||
|
||||
instance.backgroundImagePath = "";
|
||||
|
||||
instance.useBackgroundImage = false;
|
||||
|
||||
instance.features = 0;
|
||||
|
||||
instance.featureNames = vector_char_pointer_newPointer();
|
||||
|
||||
element_constructor( &instance);
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
element * element_newPointer() {
|
||||
|
||||
struct element * pointer = malloc( sizeof ( struct element ) );
|
||||
|
||||
pointer->position = vector3_new( 0, 0, 0 );
|
||||
|
||||
pointer->size = vector2_new( 0, 0 );
|
||||
|
||||
pointer->backgroundColor = vector3_new( 0, 0, 0 );
|
||||
|
||||
pointer->originalPosition = vector3_new( 0, 0, 0 );
|
||||
|
||||
pointer->originalSize = vector2_new( 0, 0 );
|
||||
|
||||
pointer->originalBackgroundColor = vector3_new( 0, 0, 0 );
|
||||
|
||||
pointer->opacity = 1;
|
||||
|
||||
pointer->backgroundImagePath = "";
|
||||
|
||||
pointer->useBackgroundImage = false;
|
||||
|
||||
pointer->features = 0;
|
||||
|
||||
pointer->featureNames = vector_char_pointer_newPointer();
|
||||
|
||||
element_constructor( pointer );
|
||||
|
||||
return pointer;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user