home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / landma1a / land.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-10  |  17.9 KB  |  566 lines

  1. VERSION 5.00
  2. Begin VB.Form Land 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "LandMass"
  5.    ClientHeight    =   8715
  6.    ClientLeft      =   45
  7.    ClientTop       =   615
  8.    ClientWidth     =   10455
  9.    FillStyle       =   0  'Solid
  10.    Icon            =   "Land.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   8715
  15.    ScaleWidth      =   10455
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.TextBox Selection 
  18.       Alignment       =   2  'Center
  19.       Height          =   285
  20.       Left            =   7440
  21.       TabIndex        =   7
  22.       Top             =   2280
  23.       Width           =   855
  24.    End
  25.    Begin VB.CommandButton BorderBut 
  26.       Caption         =   "Bordering"
  27.       Height          =   375
  28.       Left            =   7440
  29.       TabIndex        =   6
  30.       Top             =   2640
  31.       Width           =   855
  32.    End
  33.    Begin VB.PictureBox Ocean 
  34.       AutoRedraw      =   -1  'True
  35.       AutoSize        =   -1  'True
  36.       Height          =   7140
  37.       Left            =   9240
  38.       Picture         =   "Land.frx":0442
  39.       ScaleHeight     =   7080
  40.       ScaleWidth      =   9720
  41.       TabIndex        =   4
  42.       Top             =   4920
  43.       Visible         =   0   'False
  44.       Width           =   9780
  45.    End
  46.    Begin VB.PictureBox LandMap 
  47.       AutoRedraw      =   -1  'True
  48.       AutoSize        =   -1  'True
  49.       Height          =   3180
  50.       Left            =   0
  51.       Picture         =   "Land.frx":4B344
  52.       ScaleHeight     =   3120
  53.       ScaleWidth      =   10560
  54.       TabIndex        =   3
  55.       Top             =   5400
  56.       Visible         =   0   'False
  57.       Width           =   10620
  58.    End
  59.    Begin VB.CommandButton RedrawBut 
  60.       Caption         =   "Redraw"
  61.       Height          =   375
  62.       Left            =   7440
  63.       TabIndex        =   2
  64.       Top             =   4440
  65.       Width           =   855
  66.    End
  67.    Begin VB.CommandButton GoBut 
  68.       Caption         =   "Go!"
  69.       Height          =   375
  70.       Left            =   7440
  71.       TabIndex        =   0
  72.       Top             =   840
  73.       Width           =   855
  74.    End
  75.    Begin VB.Label SelectionText 
  76.       Caption         =   "Selection:"
  77.       BeginProperty Font 
  78.          Name            =   "MS Sans Serif"
  79.          Size            =   8.25
  80.          Charset         =   0
  81.          Weight          =   700
  82.          Underline       =   0   'False
  83.          Italic          =   0   'False
  84.          Strikethrough   =   0   'False
  85.       EndProperty
  86.       Height          =   255
  87.       Left            =   7440
  88.       TabIndex        =   5
  89.       Top             =   2040
  90.       Width           =   975
  91.    End
  92.    Begin VB.Label Commentary 
  93.       Caption         =   "Running Commentary Text."
  94.       Height          =   255
  95.       Left            =   360
  96.       TabIndex        =   1
  97.       Top             =   5040
  98.       Width           =   7695
  99.    End
  100.    Begin VB.Menu MenuFile 
  101.       Caption         =   "File"
  102.       Begin VB.Menu MenuExit 
  103.          Caption         =   "Exit"
  104.       End
  105.    End
  106.    Begin VB.Menu MenuOptions 
  107.       Caption         =   "Terraform"
  108.       Begin VB.Menu MenuCountrySize 
  109.          Caption         =   "Country Size"
  110.          Begin VB.Menu MenuSize 
  111.             Caption         =   "Tiny Independently-Owned Countries"
  112.             Index           =   1
  113.          End
  114.          Begin VB.Menu MenuSize 
  115.             Caption         =   "Small Third-World Countries"
  116.             Index           =   2
  117.          End
  118.          Begin VB.Menu MenuSize 
  119.             Caption         =   "Medium OPEC Countries"
  120.             Checked         =   -1  'True
  121.             Index           =   3
  122.          End
  123.          Begin VB.Menu MenuSize 
  124.             Caption         =   "Large First-World Countries"
  125.             Index           =   4
  126.          End
  127.          Begin VB.Menu MenuSize 
  128.             Caption         =   "Continents"
  129.             Index           =   5
  130.          End
  131.       End
  132.       Begin VB.Menu MenuCountrySizeProp 
  133.          Caption         =   "Country Size Proportions"
  134.          Begin VB.Menu MenuProp 
  135.             Caption         =   "Proportional Countries"
  136.             Index           =   1
  137.          End
  138.          Begin VB.Menu MenuProp 
  139.             Caption         =   "Somewhat Proportional Countries"
  140.             Checked         =   -1  'True
  141.             Index           =   2
  142.          End
  143.          Begin VB.Menu MenuProp 
  144.             Caption         =   "Unproportional Countries"
  145.             Index           =   3
  146.          End
  147.       End
  148.       Begin VB.Menu MenuCountryShapes 
  149.          Caption         =   "Country Shapes"
  150.          Begin VB.Menu MenuShape 
  151.             Caption         =   "Normal (no artificial distortion)"
  152.             Index           =   1
  153.          End
  154.          Begin VB.Menu MenuShape 
  155.             Caption         =   "Irregular"
  156.             Checked         =   -1  'True
  157.             Index           =   2
  158.          End
  159.          Begin VB.Menu MenuShape 
  160.             Caption         =   "Very Irregular"
  161.             Index           =   3
  162.          End
  163.       End
  164.       Begin VB.Menu MenuMinLakeSize 
  165.          Caption         =   "Minimum Allowed Lake Size"
  166.          Begin VB.Menu MenuLakeSize 
  167.             Caption         =   "No Lake Correction"
  168.             Index           =   1
  169.          End
  170.          Begin VB.Menu MenuLakeSize 
  171.             Caption         =   "Tiny Lakes"
  172.             Index           =   2
  173.          End
  174.          Begin VB.Menu MenuLakeSize 
  175.             Caption         =   "Medium Lakes"
  176.             Checked         =   -1  'True
  177.             Index           =   3
  178.          End
  179.          Begin VB.Menu MenuLakeSize 
  180.             Caption         =   "Large Lakes"
  181.             Index           =   4
  182.          End
  183.       End
  184.       Begin VB.Menu MenuGlobal 
  185.          Caption         =   "Approximate Land:Water ratio"
  186.          Begin VB.Menu MenuPct 
  187.             Caption         =   "1:9"
  188.             Index           =   1
  189.          End
  190.          Begin VB.Menu MenuPct 
  191.             Caption         =   "1:3"
  192.             Index           =   2
  193.          End
  194.          Begin VB.Menu MenuPct 
  195.             Caption         =   "1:1"
  196.             Index           =   3
  197.          End
  198.          Begin VB.Menu MenuPct 
  199.             Caption         =   "3:1"
  200.             Checked         =   -1  'True
  201.             Index           =   4
  202.          End
  203.          Begin VB.Menu MenuPct 
  204.             Caption         =   "9:1"
  205.             Index           =   5
  206.          End
  207.       End
  208.       Begin VB.Menu MenuIsle 
  209.          Caption         =   "Islands"
  210.          Begin VB.Menu MenuIslands 
  211.             Caption         =   "No Islands"
  212.             Index           =   1
  213.          End
  214.          Begin VB.Menu MenuIslands 
  215.             Caption         =   "Some Islands"
  216.             Checked         =   -1  'True
  217.             Index           =   2
  218.          End
  219.          Begin VB.Menu MenuIslands 
  220.             Caption         =   "Lots of Islands"
  221.             Index           =   3
  222.          End
  223.       End
  224.    End
  225.    Begin VB.Menu MenuDraw 
  226.       Caption         =   "Draw"
  227.       Begin VB.Menu MenuBorderChoice 
  228.          Caption         =   "Borders"
  229.          Begin VB.Menu MenuBorders 
  230.             Caption         =   "Big Lines"
  231.             Index           =   1
  232.          End
  233.          Begin VB.Menu MenuBorders 
  234.             Caption         =   "Big Dots"
  235.             Index           =   2
  236.          End
  237.          Begin VB.Menu MenuBorders 
  238.             Caption         =   "Hash Marks"
  239.             Checked         =   -1  'True
  240.             Index           =   3
  241.          End
  242.          Begin VB.Menu MenuBorders 
  243.             Caption         =   "Small Dots"
  244.             Index           =   4
  245.          End
  246.          Begin VB.Menu MenuBorders 
  247.             Caption         =   "None"
  248.             Index           =   5
  249.          End
  250.       End
  251.       Begin VB.Menu MenuColors 
  252.          Caption         =   "Colors"
  253.          Begin VB.Menu MenuColor 
  254.             Caption         =   "Earth Tones"
  255.             Checked         =   -1  'True
  256.             Index           =   1
  257.          End
  258.          Begin VB.Menu MenuColor 
  259.             Caption         =   "Black && White"
  260.             Index           =   2
  261.          End
  262.       End
  263.    End
  264.    Begin VB.Menu MenuHelp 
  265.       Caption         =   "Help"
  266.       Begin VB.Menu MenuAbout 
  267.          Caption         =   "About"
  268.       End
  269.       Begin VB.Menu MenuTextFile 
  270.          Caption         =   "View Text File"
  271.       End
  272.    End
  273. Attribute VB_Name = "Land"
  274. Attribute VB_GlobalNameSpace = False
  275. Attribute VB_Creatable = False
  276. Attribute VB_PredeclaredId = True
  277. Attribute VB_Exposed = False
  278. 'LandMass generator by Jason Merlo  10/10/99
  279. 'jmerlo@austin.rr.com
  280. 'jason.merlo@frco.com
  281. 'http://home.austin.rr.com/smozzie
  282. Option Explicit
  283. Option Base 1
  284. Dim i As Long
  285. Dim MyMap As Map
  286. Dim CurrentMouse As Long
  287. Dim RollOver As Boolean
  288. Dim MinLakeSize As Integer
  289. Dim MaxCountrySize As Integer
  290. Dim NumCountries As Integer
  291. Dim CFGCountrySize As Integer
  292. Dim CFGCheckedPct As Integer
  293. Dim CFGIslands As Integer
  294. Dim CFGLakeSize As Integer
  295. Dim CFGCoast As Integer
  296. Dim CFGProportion As Integer
  297. Dim CFGShape As Integer
  298. Dim CFGColor As Integer
  299. Dim CFGBorders As Integer
  300. Dim LandPct As Double
  301. Dim PropPct As Double
  302. Dim ShapePct As Double
  303. Dim CoastPctKeep As Double
  304. Dim IslePctKeep As Double
  305. Private Sub GoBut_Click()
  306. GoBut.Enabled = False
  307. RedrawBut.Enabled = False
  308. SelectionText.Enabled = False
  309. Selection.Text = ""
  310. Selection.Enabled = False
  311. BorderBut.Enabled = False
  312. RollOver = False
  313. Set MyMap = New Map
  314. Commentary.Caption = "Creating map..."
  315. DoEvents
  316. 'Collect the menu settings.
  317. Call CollectMenuSettings
  318. 'Clear the previous display.
  319. Call DrawBkg
  320. 'This is the syntax for building a map.
  321. MyMap.CreateMap NumCountries, MaxCountrySize, MinLakeSize, LandPct, PropPct, _
  322.      ShapePct, CoastPctKeep, IslePctKeep, CFGColor, CFGIslands
  323. 'This command draws the map.
  324. MyMap.DisplayMap LandMap.hDC, Land.hDC, CFGBorders
  325. GoBut.Enabled = True
  326. RedrawBut.Enabled = True
  327. SelectionText.Enabled = True
  328. Selection.Enabled = True
  329. RollOver = True
  330. Commentary.Caption = "LandMass is finished. " & MyMap.NumCountries & " countries present on this map."
  331. End Sub
  332. Private Sub MenuAbout_Click()
  333. About.Show vbModal
  334. End Sub
  335. Private Sub MenuExit_Click()
  336. End Sub
  337. Private Sub Form_Load()
  338. Dim WinWidth As Long
  339. Dim WinHeight As Long
  340. Randomize
  341. WinWidth = 750 * Screen.TwipsPerPixelX
  342. WinHeight = 550 * Screen.TwipsPerPixelY
  343. 'Set up window position and dimensions.
  344. Land.Width = WinWidth
  345. Land.Height = WinHeight
  346. Land.ScaleWidth = WinWidth
  347. Land.ScaleHeight = WinHeight
  348. Land.ScaleMode = 1
  349. DoEvents
  350. 'Add other controls.
  351. GoBut.Left = Land.ScaleWidth - (70 * Screen.TwipsPerPixelX)
  352. GoBut.Top = (10 * Screen.TwipsPerPixelY)
  353. RedrawBut.Left = Land.ScaleWidth - (70 * Screen.TwipsPerPixelX)
  354. RedrawBut.Top = Land.ScaleHeight - (100 * Screen.TwipsPerPixelY)
  355. SelectionText.Left = Land.ScaleWidth - (70 * Screen.TwipsPerPixelX)
  356. SelectionText.Top = 110 * Screen.TwipsPerPixelY
  357. Selection.Left = Land.ScaleWidth - (70 * Screen.TwipsPerPixelX)
  358. Selection.Top = 125 * Screen.TwipsPerPixelY
  359. BorderBut.Left = Land.ScaleWidth - (70 * Screen.TwipsPerPixelX)
  360. BorderBut.Top = 150 * Screen.TwipsPerPixelY
  361. SelectionText.Enabled = False
  362. Selection.Enabled = False
  363. BorderBut.Enabled = False
  364. GoBut.Enabled = True
  365. RedrawBut.Enabled = False
  366. RollOver = False
  367. Commentary.Left = Land.Left + (10 * Screen.TwipsPerPixelX)
  368. Commentary.Top = Land.ScaleHeight - (18 * Screen.TwipsPerPixelY)
  369. Commentary.Caption = "LandMass is idle."
  370. End Sub
  371. Private Sub MenuSize_Click(Index As Integer)
  372. For i = 1 To 5
  373.   MenuSize(i).Checked = False
  374. Next i
  375. MenuSize(Index).Checked = True
  376. End Sub
  377. Private Sub MenuLakeSize_Click(Index As Integer)
  378. For i = 1 To 4
  379.   MenuLakeSize(i).Checked = False
  380. Next i
  381. MenuLakeSize(Index).Checked = True
  382. End Sub
  383. Private Sub MenuPct_Click(Index As Integer)
  384. For i = 1 To 5
  385.   MenuPct(i).Checked = False
  386. Next i
  387. MenuPct(Index).Checked = True
  388. End Sub
  389. Private Sub MenuIslands_Click(Index As Integer)
  390. For i = 1 To 3
  391.   MenuIslands(i).Checked = False
  392. Next i
  393. MenuIslands(Index).Checked = True
  394. End Sub
  395. Private Sub MenuShape_Click(Index As Integer)
  396. For i = 1 To 3
  397.   MenuShape(i).Checked = False
  398. Next i
  399. MenuShape(Index).Checked = True
  400. End Sub
  401. Private Sub MenuProp_Click(Index As Integer)
  402. For i = 1 To 3
  403.   MenuProp(i).Checked = False
  404. Next i
  405. MenuProp(Index).Checked = True
  406. End Sub
  407. Private Sub MenuBorders_Click(Index As Integer)
  408. For i = 1 To 5
  409.   MenuBorders(i).Checked = False
  410. Next i
  411. MenuBorders(Index).Checked = True
  412. End Sub
  413. Private Sub MenuColor_Click(Index As Integer)
  414. For i = 1 To 2
  415.   MenuColor(i).Checked = False
  416. Next i
  417. MenuColor(Index).Checked = True
  418. End Sub
  419. Private Sub MenuTextFile_click()
  420. Shell "Notepad.exe LandMass.txt", vbNormalFocus
  421. End Sub
  422. Private Sub RedrawBut_Click()
  423. Dim l As Integer
  424. 'Grab the menu settings, as some of these are cosmetic.
  425. Call CollectMenuSettings
  426. 'Set up the CountryColor array.
  427. Select Case CFGColor
  428.   Case 1:  For l = 1 To NumCountries
  429.              MyMap.CountryColor(l) = l Mod 10    'Earth Tones
  430.            Next l
  431.   Case 2:  For l = 1 To NumCountries
  432.              MyMap.CountryColor(l) = 10    'White
  433.            Next l
  434. End Select
  435. 'Clear the previous display.
  436. Call DrawBkg
  437. 'Draw the map!
  438. MyMap.DisplayMap LandMap.hDC, Land.hDC, CFGBorders
  439. End Sub
  440. Private Sub StopBut_Click()
  441. End Sub
  442. Public Sub CollectMenuSettings()
  443. 'This subroutine grabs the checked info from the menus.
  444. For i = 1 To 5
  445.   If MenuSize(i).Checked = True Then CFGCountrySize = i
  446.   If MenuPct(i).Checked = True Then CFGCheckedPct = i
  447.   If MenuBorders(i).Checked = True Then CFGBorders = i
  448.   If i <= 4 Then
  449.     If MenuLakeSize(i).Checked = True Then CFGLakeSize = i
  450.   End If
  451.   If i <= 3 Then
  452.     If MenuIslands(i).Checked = True Then CFGIslands = i
  453.     If MenuShape(i).Checked = True Then CFGShape = i
  454.     If MenuProp(i).Checked = True Then CFGProportion = i
  455.   End If
  456.   If i <= 2 Then
  457.     If MenuColor(i).Checked = True Then CFGColor = i
  458.     End If
  459. Next i
  460. 'Now parse the menu settings.
  461. 'Get the number of countries that will fit in the
  462. 'selected area based on country size.
  463. MaxCountrySize = Int((CFGCountrySize * 32.5) - 12.5)      '20-150 blocks per country.
  464. Select Case CFGCheckedPct:
  465.   Case 1:    LandPct = 0.1
  466.   Case 2:    LandPct = 0.25
  467.   Case 3:    LandPct = 0.5
  468.   Case 4:    LandPct = 0.75
  469.   Case 5:    LandPct = 0.9
  470. End Select
  471. NumCountries = Int((MyMap.Xsize * MyMap.Ysize * LandPct) / MaxCountrySize)
  472. If NumCountries = 0 Then NumCountries = 1
  473. If NumCountries > 998 Then NumCountries = 998
  474. 'Get the proportional size variance.
  475. Select Case CFGProportion:
  476.   Case 1:    PropPct = 0.1
  477.   Case 2:    PropPct = 0.45
  478.   Case 3:    PropPct = 0.75
  479. End Select
  480. 'Get the minimum allowable lake size.
  481. Select Case CFGLakeSize
  482.   Case 1:    MinLakeSize = 0
  483.   Case 2:    MinLakeSize = 5
  484.   Case 3:    MinLakeSize = 10
  485.   Case 4:    MinLakeSize = 20
  486. End Select
  487. 'Get the percentage irregularity.
  488. Select Case CFGShape
  489.   Case 1:    ShapePct = 1
  490.   Case 2:    ShapePct = 0.7
  491.   Case 3:    ShapePct = 0.3
  492. End Select
  493. 'Get the island parameters.
  494. If CFGIslands = 2 Then
  495.   CoastPctKeep = 0.99
  496.   IslePctKeep = 0.01
  497. End If
  498. End Sub
  499. Public Sub DrawBkg()
  500. If CFGColor = 1 Then
  501.   BitBlt hDC, 10, 0, 656, 472, Ocean.hDC, 0, 0, SRCCOPY
  502.   Land.Line (10 * Screen.TwipsPerPixelX, 0)-(657 * Screen.TwipsPerPixelX, 471 * Screen.TwipsPerPixelY), vbBlack, BF
  503. End If
  504. End Sub
  505. Private Sub BorderBut_Click()
  506. Dim Selected As Integer
  507. Dim l As Integer
  508. Dim m As Integer
  509. Selected = Val(Selection.Text)
  510. If Selected < 1 Or Selected > MyMap.LakeCode - 1 Then Selection.Text = "": Exit Sub
  511. 'If land is selected, find all non-water neighbors.
  512. If Selected < 999 Then
  513.   For l = 1 To MyMap.MaxNeighbors
  514.     If MyMap.Neighbors(Selected, l) <> 0 And MyMap.Neighbors(Selected, l) < 999 Then
  515.       MyMap.CountryColor(MyMap.Neighbors(Selected, l)) = 11
  516.     End If
  517.   Next l
  518. End If
  519. 'If water is selected, find all countries who have this lake as a neighbor.
  520. If Selected > 999 Then
  521.   For l = 1 To NumCountries
  522.     For m = 1 To MyMap.MaxNeighbors
  523.       If MyMap.Neighbors(l, m) = Selected Then
  524.         MyMap.CountryColor(l) = 11
  525.       End If
  526.     Next m
  527.   Next l
  528. End If
  529. MyMap.DisplayMap LandMap.hDC, Land.hDC, CFGBorders
  530. End Sub
  531. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  532. Dim MapX As Integer
  533. Dim MapY As Integer
  534. If RollOver = False Or Selection.Enabled = False Then Exit Sub
  535.   MapX = Int((Int(x / Screen.TwipsPerPixelX) - 10) / 8) + 1
  536.   MapY = Int((Int(y / Screen.TwipsPerPixelY)) / 8) + 1
  537.   If (MapX > 0) And (MapX <= MyMap.Xsize) And (MapY > 0) And (MapY <= MyMap.Ysize) Then
  538.     If Button = 1 Then
  539.       Selection.Text = CurrentMouse
  540.       BorderBut.Enabled = True
  541.     End If
  542.   End If
  543. End Sub
  544. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  545. Dim MapX As Integer
  546. Dim MapY As Integer
  547. If RollOver = True Then
  548.   'These instructions calculate the map coordinates where the mouse is.
  549.   MapX = Int((Int(x / Screen.TwipsPerPixelX) - 10) / 8) + 1
  550.   MapY = Int((Int(y / Screen.TwipsPerPixelY)) / 8) + 1
  551.   If (MapX > 0) And (MapX <= MyMap.Xsize) And (MapY > 0) And (MapY <= MyMap.Ysize) Then
  552.     CurrentMouse = MyMap.Grid(MapX, MapY)
  553.     If CurrentMouse = 0 Or CurrentMouse = 999 Then
  554.       Commentary.Caption = "Water"
  555.     ElseIf CurrentMouse < 999 Then
  556.       Commentary.Caption = "Country number " & CurrentMouse & " of " & NumCountries
  557.     ElseIf CurrentMouse > 999 Then
  558.       Commentary.Caption = "Water mass number " & CurrentMouse
  559.     End If
  560.   End If
  561. End If
  562. End Sub
  563. Private Sub Form_Unload(Cancel As Integer)
  564. Unload Me
  565. End Sub
  566.