Your test variable is of the type Test*. This is a pointer to an object of type Test. Since it is a pointer, it is neither a struct nor a class. You have to follow the pointer and then do the .
(*test).Add = 1;
Another way of writing the exact same thing is
test->Add=1;
You could have enriched Test*, so that test.Add makes sense.
enrichTest*{intAdd{set{this->Add=value+2;}}}
That is why it is telling you it has to be a struct, class or something which is enriched.
Void is not a valid type for a property. I assume you mean it to be int in this case. Also, in a class, the this keyword will be a pointer to the current object. Sho you should use this->i instead of this.i.
Actually, you don't even need to write this, since you don't have any conflicting local variables, you can just write i instead of this->i.
Anyway.. it seems weird to me to use a struct just to get a naming prefix - that seems to be the function of namespaces, so I think something like c# style namespaces might be better
As it is now, the implementation of: struct Foo { struct Bar { static int Derp = 0; } }
Could easily be converted to Foo_Bar_Derp when compiled, instead of:
struct Foo { Bar bar; }
struct Bar { static int Derp; }
Not only does that create less readable code, but also a longer time to write the code, and would be compiled differently (would it not? Assuming we talk about no level of optimization right now)?
I'm not sure I follow your point here. As it is now, you can't nest structs/classes. Also, in the second code you would not be able to use foo.bar.Derp, since Derp is a static variable, and must be used with Bar.Derp (or, in next version, with Derp from inside Bar).
Nested namespaces and structs/classes.. Well, it is certainly possible to implement, but it would take a lot of time to do, and it is really only a convenience. I think I will prioritize other features for now, such as being able to do reliable null checks for pointers. But progress on that is slow at the moment due to a school project.
Dahm. I'm very sorry about breaking your code.. That change was a mistake, and I will fix it for the next update.
I'll also make it possible to copy errors as text with ctrl c.
Yeah, I haven't been very active on this for some time - due to christmas, exams and swtor that I wanted to try. I should be able to get some work done on it soon though - just one nasty exam left, and I don't play as much swtor now that I really only need to raid.
The server was down for maintenance for a while.. It happens from time to time.
You got a lot of code, and very few green lines.
As I understand it. You want to implement delegates using triggers instead of if-sentences, and add support for interfaces, both of which seems doable.
I want to get the dialog part finished before moving on to something else though.
I got blending working for all but subtract, which for some reason acts up and gives me a purple image, regardless of source or destination colors. For the others, it was just those 3 properties.
I have tried again and again to make it load the map without having to restart it. If you know how, I would love to know.
If you are talking about my ftp server..
I rent a virtual server at https://www.hosteurope.de/
And use the installed Microsoft IIS ftp server. For the error reports and libraries, I wrote my own server side program.
I just have to set GraphicsDevice.RenderState.SourceBlend, GraphicsDevice.RenderState.DestinationBlend and GraphicsDevice.RenderState.BlendFunction to the right stuff.. There are some examples here http://forums.create.msdn.com/forums/p/75039/457237.aspx
It's not that much work.
Edit:
About multiple draw calls.. I read somewhere a while ago that for rendering the same thing many times, there is some way to get away with one draw call by sending an array of world matrices to directx, if I remember correctly. This was motivated by that this would be a lot cheaper than calling draw many times.
But it doesn't matter in this case. Performance is not an issue.
I am using the spritebatch to draw.. But rather than make multiple draw calls for different regions of the texture, I use the effect file to calculate what texture coordinate to use (for the different image types). First of all, this should be faster, simply because I get fewer draw calls, and I can push some arithmetic to the gpu. The speed gain probably isn't noticeable though, since the scene is so simple. Also, I think this solution is cleaner.. I have fewer variables to keep track of - just tex coord x and y. Otherwise, I would need rotation, source rectangle, destination rectangle and origin.
Some of my draw code:
foreach(Dialogdinitems){//A list of what should be rendered, in the order it should be renderedList<AbstractControl>renders=newList<AbstractControl>();renders.Add(d);//Each dialog has a list of controls, sorted after render priorityrenders.AddRange(d.ChildControls);while(renders.Count>0){AbstractControlitem=renders[0];renders.RemoveAt(0);//A single control might add more controls to render correctly, but theese controls//wont be in the output script. //An example is that the checkbox adds an image if it is set to be checked.renders.InsertRange(0,item.ExtraControlsToRender);if(item.DrawTexture){//Set image typeEffect.CurrentTechnique=Effect.Techniques[Enum.GetName(typeof(ImageType),item.ImageType)];//Clip rectangle used to clip controls when they are dragged outside of their parent dialogSpriteBatch.GraphicsDevice.RenderState.ScissorTestEnable=true;SpriteBatch.GraphicsDevice.ScissorRectangle=item.ClipRect;Texture2Dtexture=item.Texture??defaultTexture;//Buttons/check boxes have both pressed/not pressed images in same textureEffect.Parameters["RenderingButton"].SetValue(itemisButton||itemisCheckBox);Effect.Parameters["Tiled"].SetValue(item.IsTiled);Effect.Parameters["TintColor"].SetValue(item.Color.ToVector4());Effect.Parameters["TextureSize"].SetValue(newVector2(texture.Width,texture.Height));Effect.Parameters["TargetSize"].SetValue(newVector2(item.DrawRect.Width,item.DrawRect.Height));SpriteBatch.Begin(SpriteBlendMode.AlphaBlend,SpriteSortMode.Immediate,SaveStateMode.None);//Todo: Set blend functionEffect.Begin();Effect.CurrentTechnique.Passes[0].Begin();SpriteBatch.Draw(texture,item.DrawRect,null,Color.White);SpriteBatch.End();Effect.CurrentTechnique.Passes[0].End();Effect.End();}//Draw dialog titleif(itemisDialog){Dialogdialog=(Dialog)item;if(!string.IsNullOrEmpty(dialog.Title))DrawString(dialog.Title,dialog.TitleFontRect,dialog.TitleFont,Color.White);}//Draw the control's text if neededif(itemisDialogControl){DialogControlcontrol=(DialogControl)item;if(control.DrawText&&!string.IsNullOrEmpty(control.Text))DrawString(control.Text,control.DrawRect,control.TextStyle,control.TextColor);}}}
In case you're interested.. one of my shaders:
float4HorizontalBorderPS(float2texCoord:TEXCOORD0):COLOR{float2targetCoord=texCoord*TargetSize;float2edgeSize=float2(TextureSize.y,TextureSize.y);if(TargetSize.x<2*edgeSize.x)edgeSize.x=TargetSize.x/2;if(TargetSize.y<2*edgeSize.y)edgeSize.y=TargetSize.y/2;//First, we should check what region we are in.if(targetCoord.x<edgeSize.x){if(targetCoord.y<edgeSize.y){//Top lefttexCoord.x=targetCoord.x/(TextureSize.y*10);texCoord.y=targetCoord.y/TextureSize.y;}elseif(TargetSize.y-targetCoord.y<edgeSize.y){//Bottom lefttexCoord.x=targetCoord.x/(TextureSize.y*10)+0.2;texCoord.y=(targetCoord.y-TargetSize.y+TextureSize.y)/TextureSize.y;}else{//Left bordertexCoord.x=targetCoord.x/(TextureSize.y*10)+0.6;texCoord.y=((targetCoord.y-edgeSize.y)/TextureSize.y)%1;}}elseif(TargetSize.x-targetCoord.x<edgeSize.x){if(targetCoord.y<edgeSize.y){//Top righttexCoord.x=(targetCoord.x-TargetSize.x+TextureSize.y)/(TextureSize.y*10)+0.1;texCoord.y=targetCoord.y/TextureSize.y;}elseif(TargetSize.y-targetCoord.y<edgeSize.y){//Bottom righttexCoord.x=(targetCoord.x-TargetSize.x+TextureSize.y)/(TextureSize.y*10)+0.3;texCoord.y=(targetCoord.y-TargetSize.y+TextureSize.y)/TextureSize.y;}else{//Right bordertexCoord.x=(targetCoord.x-TargetSize.x+TextureSize.y)/(TextureSize.y*10)+0.7;texCoord.y=((targetCoord.y-edgeSize.y)/TextureSize.y)%1;}}else{if(targetCoord.y<edgeSize.y){//Top bordertexCoord.x=((targetCoord.x-edgeSize.x)/(TextureSize.y))%1;texCoord.y=targetCoord.y/TextureSize.y;//Need to rotatefloattemp=texCoord.x;texCoord.x=texCoord.y;texCoord.y=1-temp;//Ajust to regiontexCoord.x=texCoord.x/10+0.4;}elseif(TargetSize.y-targetCoord.y<edgeSize.y){//Bottom bordertexCoord.x=((targetCoord.x-edgeSize.x)/(TextureSize.y))%1;texCoord.y=(targetCoord.y-TargetSize.y+TextureSize.y)/TextureSize.y;//Need to rotatefloattemp=texCoord.x;texCoord.x=texCoord.y;texCoord.y=1-temp;//Ajust to regiontexCoord.x=texCoord.x/10+0.5;}else{//Middle filltexCoord.x=(((targetCoord.x-edgeSize.x)/TextureSize.y)%1)/10+0.8;texCoord.y=((targetCoord.y-edgeSize.y)/TextureSize.y)%1;}}if(RenderingButton)texCoord.y/=2;float4color=tex2D(ScreenS,texCoord);returncolor*TintColor;}
Well, the reason is that before xna 4.0 came out, I was working on a space game in xna (kindda like freelancer). When 4.0 came out, I looked into the changes to see if I wanted to port it to 4.0, and decided that I liked the way the coding was done in 3.1 better. So I guess it's just because i'm more used to 3.1 than 4.0. The fonts do annoy me, and I don't know how to fix it, but I'm also not guaranteed that it will look right in 4.0.
Hmm. the front page stuff is really quite old.. I should probably rewrite it.. Right now, I can run statistic tools on downloads/accesses to the ftp server. Since the program checks there for new versions each time it is launched, it's a good source of info for me.
Edit:
Okay, it wasn't on the front page. Still - it's not a problem anymore.
The reason It looks to me that this is the issue is that all my shaders are for 3.0, except horizontal border, which is 2.0.. I'll release this, and we'll see if it works.
Hmm.... what graphics card do you have? Does it support v3.0 shaders? I had some trouble with too many operations for a v2.0 shader, so I just ramped up the required version.. but I could look into alternatives.
Yeah, adding support for extra image types should be fairly trivial, and I'll remove that useless option.
I already give you the option to set the target screen height, as I do in my video - which affects scale.
Edit:
I'll lower the required pixel shader version from 3.0 to 2.0a.. hope most people can run that.
Your test variable is of the type Test*. This is a pointer to an object of type Test. Since it is a pointer, it is neither a struct nor a class. You have to follow the pointer and then do the .
(*test).Add = 1;
Another way of writing the exact same thing is
You could have enriched Test*, so that test.Add makes sense.
That is why it is telling you it has to be a struct, class or something which is enriched.
Void is not a valid type for a property. I assume you mean it to be int in this case. Also, in a class, the this keyword will be a pointer to the current object. Sho you should use this->i instead of this.i.
Actually, you don't even need to write this, since you don't have any conflicting local variables, you can just write i instead of this->i.
Actually, as it is, you can write
To get your Foo.Bar.Derp.
Anyway.. it seems weird to me to use a struct just to get a naming prefix - that seems to be the function of namespaces, so I think something like c# style namespaces might be better
I'm not sure I follow your point here. As it is now, you can't nest structs/classes. Also, in the second code you would not be able to use foo.bar.Derp, since Derp is a static variable, and must be used with Bar.Derp (or, in next version, with Derp from inside Bar).
Nested namespaces and structs/classes.. Well, it is certainly possible to implement, but it would take a lot of time to do, and it is really only a convenience. I think I will prioritize other features for now, such as being able to do reliable null checks for pointers. But progress on that is slow at the moment due to a school project.
Dahm. I'm very sorry about breaking your code.. That change was a mistake, and I will fix it for the next update.
I'll also make it possible to copy errors as text with ctrl c.
Yeah, I haven't been very active on this for some time - due to christmas, exams and swtor that I wanted to try. I should be able to get some work done on it soon though - just one nasty exam left, and I don't play as much swtor now that I really only need to raid.
The server was down for maintenance for a while.. It happens from time to time.
You got a lot of code, and very few green lines.
As I understand it. You want to implement delegates using triggers instead of if-sentences, and add support for interfaces, both of which seems doable.
I want to get the dialog part finished before moving on to something else though.
I got blending working for all but subtract, which for some reason acts up and gives me a purple image, regardless of source or destination colors. For the others, it was just those 3 properties.
I have tried again and again to make it load the map without having to restart it. If you know how, I would love to know.
If you are talking about my ftp server..
I rent a virtual server at https://www.hosteurope.de/
And use the installed Microsoft IIS ftp server. For the error reports and libraries, I wrote my own server side program.
I just have to set GraphicsDevice.RenderState.SourceBlend, GraphicsDevice.RenderState.DestinationBlend and GraphicsDevice.RenderState.BlendFunction to the right stuff.. There are some examples here http://forums.create.msdn.com/forums/p/75039/457237.aspx
It's not that much work.
Edit:
About multiple draw calls.. I read somewhere a while ago that for rendering the same thing many times, there is some way to get away with one draw call by sending an array of world matrices to directx, if I remember correctly. This was motivated by that this would be a lot cheaper than calling draw many times.
But it doesn't matter in this case. Performance is not an issue.
I am using the spritebatch to draw.. But rather than make multiple draw calls for different regions of the texture, I use the effect file to calculate what texture coordinate to use (for the different image types). First of all, this should be faster, simply because I get fewer draw calls, and I can push some arithmetic to the gpu. The speed gain probably isn't noticeable though, since the scene is so simple. Also, I think this solution is cleaner.. I have fewer variables to keep track of - just tex coord x and y. Otherwise, I would need rotation, source rectangle, destination rectangle and origin.
Some of my draw code:
In case you're interested.. one of my shaders:
Well, the reason is that before xna 4.0 came out, I was working on a space game in xna (kindda like freelancer). When 4.0 came out, I looked into the changes to see if I wanted to port it to 4.0, and decided that I liked the way the coding was done in 3.1 better. So I guess it's just because i'm more used to 3.1 than 4.0. The fonts do annoy me, and I don't know how to fix it, but I'm also not guaranteed that it will look right in 4.0.
Hmm. the front page stuff is really quite old.. I should probably rewrite it.. Right now, I can run statistic tools on downloads/accesses to the ftp server. Since the program checks there for new versions each time it is launched, it's a good source of info for me.
Edit:
Okay, it wasn't on the front page. Still - it's not a problem anymore.
The reason It looks to me that this is the issue is that all my shaders are for 3.0, except horizontal border, which is 2.0.. I'll release this, and we'll see if it works.
Hmm.... what graphics card do you have? Does it support v3.0 shaders? I had some trouble with too many operations for a v2.0 shader, so I just ramped up the required version.. but I could look into alternatives.
Yeah, adding support for extra image types should be fairly trivial, and I'll remove that useless option.
I already give you the option to set the target screen height, as I do in my video - which affects scale.
Edit:
I'll lower the required pixel shader version from 3.0 to 2.0a.. hope most people can run that.