1. Post #521
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    I just started a class programming in C and C++ and I was trying to write like a super basic program and I am having problems getting the equation part of the code to execute...

    Code:
    # include <stdio.h>
    
    int main(void){
       float celsius, fahrenheit;
       printf("Please enter a temperature in degress Fahrenheit: ");
       scanf("%f", &fahrenheit);
       celsius = (5f / 9f) * ( (float) fahrenheit - 32f);
       printf("The temperature of %f in degrees Celsius is %f.\n", fahrenheit, celsius);
       return 0;
    }
    It just gives me zeros as the answer. I'm sure it is something really simple I just have basically no experience :P Thanks!
    You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.
    Reply With Quote Edit / Delete Mac United States Show Events Agree Agree x 1 (list)

  2. Post #522
    Gold Member
    DoctorSalt's Avatar
    January 2009
    2,638 Posts
    -snip-

    Anyways, for the c# winform guys here, is there a stigma against explicitly calling click events inside your program?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #523
    Dennab
    March 2008
    1,310 Posts
    You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.
    I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 2 (list)

  4. Post #524
    I gave ••••• enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,402 Posts
    So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time?

    Edited:

    Also, how do i do collision with vertices and the camera's position?
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  5. Post #525
    DestWa's Avatar
    September 2007
    202 Posts
    XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

    Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  6. Post #526
    Gold Member
    esalaka's Avatar
    July 2007
    10,121 Posts
    I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.
    That actually makes them doubles. Just saying.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Agree Agree x 2Informative Informative x 1 (list)

  7. Post #527
    Stary2001's Avatar
    July 2011
    41 Posts
    -whoops-
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  8. Post #528
    omnomasaur's Avatar
    May 2009
    1,357 Posts
    So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time?

    Edited:

    Also, how do i do collision with vertices and the camera's position?
    Here's a camera class I wrote for a free moving camera in XNA, and the Particle class it extends from.

    http://pastebin.com/zu0XMMNP http://pastebin.com/TGeUcX5X

    It uses a combination of a Vector3 for the change in rotation values, and updating a matrix based on them. You can then use that matrix's forward vector and multiply it (or not) to get your target.

    It's all in the UpdateViewMatrix function.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #529
    Gold Member
    DoctorSalt's Avatar
    January 2009
    2,638 Posts
    XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

    Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
    I second this question. Of course most will say to program roguelikes in some form of Curses with c++.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #530
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,458 Posts
    You can make a rougelike using literally anything you have, as long as you can output things. I suggest XNA since you know it already, but I am unfamiliar with pygame so I might be biased.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  11. Post #531
    Austech2's Avatar
    April 2011
    112 Posts
    Snip, wow oops. Wrong thread.
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  12. Post #532
    RUBY OVERLORD
    swift and shift's Avatar
    November 2011
    2,115 Posts
    So I've got this dylib that I want to dynamically link against another dylib. Anyone know how I can do that?

    Edited:

    Also, the other dylib doesn't have 'lib' in its name...
    Reply With Quote Edit / Delete Mac Australia Show Events

  13. Post #533
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    Snip: OpenGL and me do not agree. I am forcing OpenGL to agree with me instead of retreating to DirectX.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 1Programming King Programming King x 1 (list)

  14. Post #534
    I gave ••••• enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,402 Posts
    How can i do collisions with a Vector3 (XNA) and many, many vertices?

    Edited:

    Help please?
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  15. Post #535
    Goodthief's Avatar
    December 2009
    5,967 Posts
    So I'm learning java because I heard that it's the standard language in universities (I plan to move to C++ when i'm done) But i'd like to see some example programs made in java so I could know what i'm working towards. If anyone has anything impressive that they made in java I would love it if you showed me.
    Reply With Quote Edit / Delete Windows 7 Malaysia Show Events

  16. Post #536
    LOL
    Dennab
    August 2009
    2,070 Posts
    I'm trying to use Tesseract in VB.NET, and whenever I try to call Init, it either closes without a message, or it says this:



    Code:
      Try
                Dim T As New Tesseract
                Using O As New OpenFileDialog
                    With O
                        If Not .ShowDialog = DialogResult.Cancel Then
                            Dim B As Bitmap = New Bitmap(.FileName)
                            T.Init(Application.ExecutablePath, "Eng", False)
                            Dim L As List(Of Word) = T.DoOCR(B, Rectangle.Empty)
                            For Each w As Word In L
                                MessageBox.Show(w.Text)
                            Next
                        End If
                    End With
                End Using
            Catch Ex As Exception
                MessageBox.Show(Ex.Message)
            End Try
    I seriously don't know what's wrong with it.

    Edited:

    Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage?

    Getting these retarded fucking errors with Puma.NET



    I'm about to punch a hole in my monitor
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  17. Post #537
    Inplabth's Avatar
    October 2007
    2,001 Posts
    Hey guys, I've got a problem that I'm stuck on for Digital Systems Design class.

    We're supposed to take

    f(w, x, y, z) = (w*x')+(w'*y'*z')+(w'*x'*z)+(w'*x'*y*z')

    and implement it with five two-input gates or less. I've tried minterms, maxterms and genearal alegbraic manipulation but I simply cannot get this to simplify down enough to only use 5 gates. I don't need the full solution, but if someone could give me a starting point I'd sure appreciate it.

    Edited:

    Nevermind, I got it.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  18. Post #538
    Gold Member
    horsedrowner's Avatar
    January 2009
    3,720 Posts
    Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage?
    From my experience, no, there isn't.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  19. Post #539
    ===
    This was a waste of $1
    ==='s Avatar
    December 2011
    1,528 Posts
    Potentially stupid question time.

    How do you get rid of the gradient and shadow Xcode applies to tab bar images in an iOS app? I've changed the images for the bar items by selecting an imported one in the storyboard, and that just adds the effects (as expected). I'm assuming I'd have to go into AppDelegate.m and set up something like this:
    Code:
    // Customize the Home bar item
    UIImage *barItemHome = [[UIImage imageNamed:@"home.png"] 
        resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UIBarItem appearance] setBackgroundImage:barItemHome forState:UIControlStateNormal 
        barMetrics:UIBarMetricsDefault];
    This doesn't work, though, and even if it did I have no way of selecting just the "Home" bar item to apply it to and not all of the icons. Google hasn't helped me as all of the tutorials seem to work only for older iOS versions since iOS 5 decided to fuck with the way everything is called.
    Reply With Quote Edit / Delete Mac United States Show Events

  20. Post #540
    flayne's Avatar
    January 2011
    1,628 Posts
    Is there a way to force visual C++ to include macro's in a static library. For example:

    lib.h:
    Code:
    void doStuff();
    lib.cpp:
    Code:
    #include "lib.h"
    #ifdef useint
    void doStuff() {int bloop;}
    #else
    void doStuff() {bool bloop;}
    #endif
    App.cpp:
    Code:
    #define useint
    #include "lib.h"
    int main() {doStuff()}

    I say this because I am building an engine and I would like to define these macros per-build.

    Edited:

    XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

    Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
    IF you want to make a text based game you want to just make a console application like a C++ console application using cout and cin and such.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 2 (list)

  21. Post #541
    Gold Member
    HueyFreeman's Avatar
    August 2006
    193 Posts
    I'm sort of tired, so I must be making a really stupid mistake, but here it goes.

    Code:
    unsigned char m1[]="abc";
    unsigned char m2[64];
    for(int i=0; i<64; i++){
    	m2[i]='a';
    }
    
    printf("%s\n",m1);
    printf("%s\n",m2);
    Output:
    Code:
    abc
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaΜΜΜΜΜΜΜΜabc
    What's going on with the second line?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  22. Post #542
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,052 Posts
    You're missing the null terminator. ( \0 )

    The second line is actually 75 characters long because of that.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 2 (list)

  23. Post #543
    RUBY OVERLORD
    swift and shift's Avatar
    November 2011
    2,115 Posts
    Is there a way to force visual C++ to include macro's in a static library. For example:

    lib.h:
    Code:
    void doStuff();
    lib.cpp:
    Code:
    #include "lib.h"
    #ifdef useint
    void doStuff() {int bloop;}
    #else
    void doStuff() {bool bloop;}
    #endif
    App.cpp:
    Code:
    #define useint
    #include "lib.h"
    int main() {doStuff()}

    I say this because I am building an engine and I would like to define these macros per-build.
    that's not how it works, it goes by whatever macro is defined when lib.cpp is compiled.

    If you really want to do what you're trying, do something like this:

    lib.hpp:

    _doStuffInt();
    _doStuffBool();
    
    static void doStuff() {
    #ifdef useint
        _doStuffInt();
    #else
        _doStuffBool();
    #endif
    }
    

    lib.cpp:

    void _doStuffInt() {int bloop;}
    
    void _doStuffBool() {bool bloop;}
    

    (also, please don't use .h for C++ header files)
    Reply With Quote Edit / Delete Mac Australia Show Events Dumb Dumb x 2 (list)

  24. Post #544
    Gold Member
    HueyFreeman's Avatar
    August 2006
    193 Posts
    You're missing the null terminator. ( \0 )

    The second line is actually 75 characters long because of that.
    Thank goodness for Facepunch help, you can always count on someone to get a response to you quickly. Sometimes after working on a bunch of code you just need a fresh pair of eyes. You're absolutely correct, I can't believe I made such a mistake with c-style strings.

    The example above is a simplified version of what I'm actually dealing with, although I did narrow down the problem to that piece of code. In reality both m1 and m2 are hashes of data that might have multiple null-terminators in them, and the loop is a transformation on one of the hashes.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  25. Post #545
    Gold Member
    Sir Whoopsalot's Avatar
    August 2010
    22,387 Posts
    In Java, how would one go about targeting the surface of a JFrame?
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  26. Post #546
    Kamshak's Avatar
    July 2008
    418 Posts
    In Java, how would one go about targeting the surface of a JFrame?
    what do you mean by targeting and what do you mean by surface? You could replace the content frame with your own component and override drawComponent if that's what youre trying to do
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  27. Post #547
    Gold Member
    PyromanDan's Avatar
    March 2009
    3,154 Posts
    I've been working with SharpDevelop for C#, but I recently got another monitor, and although you can use vertical tabs to see more of the code/ other windows,
    is there any way to bind or link the scrollbars of the different windows so that when I scroll it in one it can scroll it as a whole? If not in SharpDevelop, are there any IDE's that might?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #548
    Gold Member
    marcin1337's Avatar
    May 2006
    876 Posts
    -Snip-

    cPannel is buggy ......
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  29. Post #549
    Tamschi's Avatar
    December 2009
    3,173 Posts
    I have a problem where the same free space is assigned to different structures in MarsMiner's saving system.

    Can you please have a look at https://github.com/Tamschi/MarsMiner...ntRangeList.cs and tell me whether the conditions are correct?

    The IntRangeList is supposed to store non-overlapping number ranges (inclusive start, exclusive end).

    Edit: Fixed it. One missing line.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  30. Post #550
    Gold Member
    marcin1337's Avatar
    May 2006
    876 Posts
    Ok this is really bugging me!

    Code:
    	 
             1	ItemNumber	int(11)			
    	 2	ItemName	varchar(100)	latin1_swedish_ci		
    	 3	Price	double					  
    	 4	AvailableQuantity	int(11)		
    	 5	Updated_Dt	datetime
    Code:
     private void Form1_Load(object sender, EventArgs e)
                {
                    //Initialize mysql connection
                    connection = new MySqlConnection(ConnectionString);
    
    
                    //Get all items in datatable
                    DTItems = GetAllItems();
    
    
                    //Fill grid with items
                    dataGridView1.DataSource = DTItems;
         
    
    
                }
    
    
                //Get all items from database into datatable
                DataTable GetAllItems()
                {
                    try
                    {
                        //prepare query to get all records from items table
                        string query = "select * from items";
                        //prepare adapter to run query
                        adapter = new MySqlDataAdapter(query, connection);
                        DataSet DS = new DataSet();
                        //get query results in dataset
                        adapter.Fill(DS);
    It shows the data that is on the Database fine


    Code:
                        // Set the INSERT command and parameter.
                        adapter.InsertCommand = new MySqlCommand(
                            "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
                            connection);
                        adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
                        adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
                        adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
                        adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
                        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
    I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

    "Column 'ItemNumber' cannot be null"

    Edited:

    Ok this is really bugging me!

    Code:
                        // Set the INSERT command and parameter.
                        adapter.InsertCommand = new MySqlCommand(
                            "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
                            connection);
                        adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
                        adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
                        adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
                        adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
                        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
    I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

    "Column 'ItemNumber' cannot be null"

    I don't know if this adds anything but I just dragged a datagriview1 onto the form, didn't modify it in anyway.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #551
    Gold Member
    DoctorSalt's Avatar
    January 2009
    2,638 Posts
    Style question for you guys (Keep in mind i'm coding in c#)
    How do you capitalize fields, properties, methods and parameters?
    The style I've been using it to use camelCase for private fields and parameters.
    Public properties and methods are PascalCase.

    Also, typically when does one add a "_" before a field (or is it method?) I've seen that before as well.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #552
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    Style question for you guys (Keep in mind i'm coding in c#)
    How do you capitalize fields, properties, methods and parameters?
    The style I've been using it to use camelCase for private fields and parameters.
    Public properties and methods are PascalCase.

    Also, typically when does one add a "_" before a field (or is it method?) I've seen that before as well.
    I use ReSharperCase.

    Reply With Quote Edit / Delete Windows 7 Finland Show Events Informative Informative x 3Useful Useful x 1 (list)

  33. Post #553
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,052 Posts
    SFML question here:

    I'm making a textbox for my game. Basically what I'm doing is drawing the box, and then the text on top.
    However there's a bit of an issue:



    As you can see, since I'm just drawing text, it just keeps going even outside.

    Is there a way to perform something similar to sf::Sprite::SetSubRect() but for sf::Text (efficiently?)
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  34. Post #554
    Map in a box's Avatar
    July 2009
    7,155 Posts
    I'm pretty sure you have to use OpenGL with SFML to clip in SFML(but I haven't used sfml much, so don't quote me on that)
    -----
    I'm making a GUI system. I have a base class, well, kind of expected, a "Panel". All other panel types derive from this, such as the button. Now for my problem. I'm implementing a parent/children system. I have that idea planned out but have no clue on how to pass input events. They have functions such as onKeyPress and onMouseDrag but I don't know how to check for the panels under the mouse by traversing the panel tree.
    ---
    In gist:
    How do I pass events down to the proper element when all I have is a panel tree?
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events

  35. Post #555
    Gold Member
    marcin1337's Avatar
    May 2006
    876 Posts
    Ok this is really bugging me!

    Code:
    	 
             1	ItemNumber	int(11)			
    	 2	ItemName	varchar(100)	latin1_swedish_ci		
    	 3	Price	double					  
    	 4	AvailableQuantity	int(11)		
    	 5	Updated_Dt	datetime
    Code:
     private void Form1_Load(object sender, EventArgs e)
                {
                    //Initialize mysql connection
                    connection = new MySqlConnection(ConnectionString);
    
    
                    //Get all items in datatable
                    DTItems = GetAllItems();
    
    
                    //Fill grid with items
                    dataGridView1.DataSource = DTItems;
         
    
    
                }
    
    
                //Get all items from database into datatable
                DataTable GetAllItems()
                {
                    try
                    {
                        //prepare query to get all records from items table
                        string query = "select * from items";
                        //prepare adapter to run query
                        adapter = new MySqlDataAdapter(query, connection);
                        DataSet DS = new DataSet();
                        //get query results in dataset
                        adapter.Fill(DS);
    It shows the data that is on the Database fine


    Code:
                        // Set the INSERT command and parameter.
                        adapter.InsertCommand = new MySqlCommand(
                            "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
                            connection);
                        adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
                        adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
                        adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
                        adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
                        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
    I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

    "Column 'ItemNumber' cannot be null"

    Edited:

    Ok this is really bugging me!

    Code:
                        // Set the INSERT command and parameter.
                        adapter.InsertCommand = new MySqlCommand(
                            "INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
                            connection);
                        adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
                        adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
                        adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
                        adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
                        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
    I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

    "Column 'ItemNumber' cannot be null"

    I don't know if this adds anything but I just dragged a datagriview1 onto the form, didn't modify it in anyway.

    oh wow that website is old. turns out all it takes now is this

    Code:
                        myMySQLCommandBuilder = new MySqlCommandBuilder(adapter);
    
                        adapter.UpdateCommand = myMySQLCommandBuilder.GetUpdateCommand();
                        adapter.DeleteCommand = myMySQLCommandBuilder.GetDeleteCommand();
                        adapter.InsertCommand = myMySQLCommandBuilder.GetInsertCommand();
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #556
    sim642's Avatar
    July 2010
    1,039 Posts
    SFML question here:

    I'm making a textbox for my game. Basically what I'm doing is drawing the box, and then the text on top.
    However there's a bit of an issue:



    As you can see, since I'm just drawing text, it just keeps going even outside.

    Is there a way to perform something similar to sf::Sprite::SetSubRect() but for sf::Text (efficiently?)
    A hacky way to do it would be to render the text into sf::RenderTexture and then render that onto you sf::RenderWindow.
    Reply With Quote Edit / Delete Windows Vista Estonia Show Events

  37. Post #557
    Glorious GNU/Linux Master Race
    kaukassus's Avatar
    May 2010
    5,162 Posts
    Literally banging my head on a wall.

    Stuck at event handling in c#, its my first time creating my own events in c#


    defined my event using

    Code:
            public delegate void NetReceivedHandler(object sender, EventArgs e, string data);
            public event NetReceivedHandler NetRec;
    and
    Code:
    public void ListenOnPort()
    {
    
    ...
    
    NetRec(this, EventArgs.Empty, cData);
    
    }

    But when I define the new eventhandler, it just won't execute the events.
    Code:
    public void init()
    {
       cNet net = new cNet()
       Thread async = new Thread(delegate() { net.StartListen( "127.0.0.1", port ); } );
       async.Start();
       net.NetRec += new cNet.NetReceivedHandler( net_NetRec );
    }
    
    private void net_NetRec( object sender, EventArgs e, string data )
    {
        Console.WriteLine( "Data: " + data );
    }
    I have no idea what I'm doing.
    Reply With Quote Edit / Delete Mac Switzerland Show Events

  38. Post #558
    Gold Member
    Smashmaster's Avatar
    April 2005
    1,506 Posts
    I'm pretty sure you have to use OpenGL with SFML to clip in SFML(but I haven't used sfml much, so don't quote me on that)
    -----
    I'm making a GUI system. I have a base class, well, kind of expected, a "Panel". All other panel types derive from this, such as the button. Now for my problem. I'm implementing a parent/children system. I have that idea planned out but have no clue on how to pass input events. They have functions such as onKeyPress and onMouseDrag but I don't know how to check for the panels under the mouse by traversing the panel tree.
    ---
    In gist:
    How do I pass events down to the proper element when all I have is a panel tree?
    I'm assuming a panel tree is a tree of everything in the UI, in no particular order of importance, besides what is a parent of what.

    I traditionally have a panel list (doubly linked lists work great for this), where the front-most panel is always at the start of the list. This makes rendering extremely easy (just render everything on the list, in order, starting at the back) Each panel can be its own tree, but the main panels (the movable and resizeable windows) are not part of any tree.

    Once you have a list, sending events is also trivial. Construct a single event object for whatever's happening (I like to separate keyboard and mouse events, though,) and just send it to every panel on the list, in order. When an event 'hits' a panel (it happens within a panel) just set a variable in it to true and continue onward. It's crucial that the event goes to every panel, so that buttons and scrollbars can be released even if the panel is blocked by something. However, when a panel sees that an event has already hit a panel, it will not let any buttons be pressed, etc.

    Oh, and what's nice about this system is that when a panel is given focus, just remove it from the list and insert it at the start. Simplicity.

    This is probably more than you need.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #559
    β˜‚β˜‚β˜‚β˜‚ β˜‚β˜‚β˜‚ β˜‚β˜‚ _β˜‚_
    Cuel's Avatar
    January 2005
    22,406 Posts
    Need help with some basic thinking in Java, I've got a working program but I feel that the structure is wrong.

    You can give the program a zip file, it will extract it and then delete all empty files and all subfolders that have empty files. So basically when it's unzipped there can be X amount of folders, and those folders can have X amount of folders (and it's likely that those folders also have subfolders, this can go on). The application needs to check each subfolder until there are no more folders, delete all empty files and if the folder is empty, delete the folder aswell.

    what would be a good way to implement this? A method that checks the mainfolder, and if there are directories in that folder, send it to another method that will clean the folder and check for more subfolders? The main problem is how I can check all folders without knowing the amounts of folders and subfolders.
    Reply With Quote Edit / Delete Windows 7 Show Events

  40. Post #560

    January 2012
    414 Posts
    Need help with some basic thinking in Java, I've got a working program but I feel that the structure is wrong.

    You can give the program a zip file, it will extract it and then delete all empty files and all subfolders that have empty files. So basically when it's unzipped there can be X amount of folders, and those folders can have X amount of folders (and it's likely that those folders also have subfolders, this can go on). The application needs to check each subfolder until there are no more folders, delete all empty files and if the folder is empty, delete the folder aswell.

    what would be a good way to implement this? A method that checks the mainfolder, and if there are directories in that folder, send it to another method that will clean the folder and check for more subfolders? The main problem is how I can check all folders without knowing the amounts of folders and subfolders.
    Recursion.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Agree Agree x 1 (list)