Author Topic: "Game as UserControl" Template [For online!]  (Read 4910 times)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
"Game as UserControl" Template [For online!]
« on: 2007-03-06, 02:33:16 PM »
Attached is an SGDK2 project which, when imported into another SGDK2 project, will allow the project to be embedded in a web page for Internet Explorer 7 with the following code:

<object id="Game" width="{Width}" height="{Height}" classid="{Filename}.exe#GameStartupControl"></object>

Where {Width} and {Height} are the game's width and height set in the properties of the project (for example, 800 and 600 in SHFL) and {Filename} is, of course, the executable's filename.  The file is runnable either as a standalone project (double-click on it) or within a web page (as above).

A few things to be sure of: I don't yet have a method of copying fmodex.dll to the correct location.  I may add this later.  For now, just copy fmodex.dll and any other dlls you may be using to your desktop to allow this to work.  Also, the game shows up immediately, but if you start playing right away, pressing Enter will cause another tab to open up in Internet Explorer, so you should click on the game first.  Selecting Quit from the menu in SHFL allows Internet Explorer to close without errors.  Otherwise, trying to close it won't work.  navigating away from the page is strongly advised against unless Quit has been selected from the menu.

As always, full-trust is required.  This time, however, it's in .NET 1.1 instead of 2.0.

So here it is:
« Last Edit: 2007-03-08, 05:54:14 PM by bluemonkmn »
Edward Dassmesser

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: "Game as UserControl" Template [For online!]
« Reply #1 on: 2007-03-06, 04:46:54 PM »
Oops, I forgot about gamepads and joysticks again.  Here's an updated version that takes into account if you have a joystick or gamepad attached to your computer.  (If you already downloaded it, just open GameForm.cs and search for SetCoop and remove the line with SetCooperativeLevel and the line below it)
« Last Edit: 2007-03-08, 05:53:51 PM by bluemonkmn »
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: "Game as UserControl" Template [For online!]
« Reply #2 on: 2007-03-07, 12:34:47 AM »
How do you give full trust?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: "Game as UserControl" Template [For online!]
« Reply #3 on: 2007-03-07, 06:13:10 AM »
1. Run the following command:
Code: [Select]
\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CasPol.exe -m -cg Trusted_Zone FullTrust2. Add the site to the trusted zone: Select Internet Options from IE's Tools menu; Go to the Security tab; Select "Trusted Sites"; Click "Sites"; Enter the URL of the site hosting the game; Un-check "Require Server Verification"; Click Add.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: "Game as UserControl" Template [For online!]
« Reply #4 on: 2007-03-07, 07:00:20 PM »
I've updated the template.  Attached is a version that allows for external dependencies.  The program will check in the registry in HKEY_CURRENT_USER/Software/Scrolling Game Development Kit/{Project Name} for a value called "Files Location".  If it doesn't find it, it will tell the user that external files are required, and will prompt them for a location to download these files to, and will save that location in the registry as the "Files Location" value.

Then it will look in the Files location (either found in the registry or just indicated by the user) for each file required.  If it doesn't find the file, it will tell the user that the file is required.  It will then ask them if they already have it.  If they do, it will ask them to locate it, and it will then copy the file to the Files location.  Otherwise, it will download the file from the same directory the program is executing from (<== Cool part) into the Files location.

The next time the game is run, if they didn't delete the files, it will automatically run the game without any prompts at all.  Some cleaning up could be done, such as adding a progress bar for downloading files, and making the messageboxes look nicer, but it is now fully functional.  The only user-required action is to specify which files are required in GameStartupControl.cs.  Also, of course, make sure the external files are present in the same directory as the exe when you put the file online.

Here is a sample of it working: http://www.beardedchild.com/files/ActiveXTest
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: "Game as UserControl" Template [For online!]
« Reply #5 on: 2007-03-08, 06:58:56 AM »
Mind if I (or you) delete the attachments on the older messages, or do you think the older versions of the project have value?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: "Game as UserControl" Template [For online!]
« Reply #6 on: 2007-03-08, 09:44:32 AM »
I don't seem to have the ability to, so go ahead.
Edward Dassmesser