home *** CD-ROM | disk | FTP | other *** search
/ Spy: Haunted House / spion.iso / data1.cab / Program_Executable_Files / _Spooky.exe / _Spooky.dxr / 00002_screen mgr.ls < prev    next >
Encoding:
Text File  |  2002-10-29  |  10.3 KB  |  404 lines

  1. property pAlertList, pAlertSizes, pSubStringTag, pLowMode, pCurMode, pOrigDepth, pLowestSetting
  2. global gDiagResult
  3.  
  4. on new me, theFieldList
  5.   set pAlertList to [:]
  6.   set pAlertSizes to [:]
  7.   repeat with fieldNum in theFieldList
  8.     set dPropName to word 1 of the name of member fieldNum
  9.     set dBoxSize to word 2 of the name of member fieldNum
  10.     set dPropText to the text of member fieldNum
  11.     addProp(pAlertList, symbol(dPropName), dPropText)
  12.     addProp(pAlertSizes, symbol(dPropName), dBoxSize)
  13.   end repeat
  14.   set pSubStringTag to "$"
  15.   set pLowMode to 0
  16.   registerDisplayRes(me)
  17.   if isPC() then
  18.     set dPrevSettings to getPrevReset(me)
  19.     set pCurMode to getAt(dPrevSettings, 1)
  20.     set pOrigDepth to getAt(dPrevSettings, 2)
  21.   else
  22.     set pOrigDepth to getBitDepth(me)
  23.   end if
  24.   set pLowestSetting to getLowestSetting(me)
  25.   initAlertFields(me, pLowestSetting)
  26.   return me
  27. end
  28.  
  29. on showAlldialogs me
  30.   set dOKList to [8]
  31.   repeat with i = 1 to count(pAlertList)
  32.     set prop to getPropAt(pAlertList, i)
  33.     if getPos(dOKList, i) then
  34.       callBox(me, prop, 0, ["OK", "OK"])
  35.       next repeat
  36.     end if
  37.     callBox(me, prop, 1, ["Yes", "No"])
  38.   end repeat
  39. end
  40.  
  41. on callBox me, theProp, theMode, theButtText
  42.   set text to getProp(pAlertList, theProp)
  43.   set size to getProp(pAlertSizes, theProp)
  44.   setupSDialogue(text, size, theMode, theButtText)
  45.   runSDialogue()
  46. end
  47.  
  48. on registerDisplayRes me
  49.   if not isPC() then
  50.     exit
  51.   end if
  52.   Register(xtra("DisplayRes"), "dres7223-5423-8472-9236")
  53. end
  54.  
  55. on InsertColorString me, theText, theSubString
  56.   if not isPC() then
  57.     exit
  58.   end if
  59.   set oldItemDelim to the itemDelimiter
  60.   set the itemDelimiter to pSubStringTag
  61.   set dNewText to EMPTY
  62.   set dItemCount to the number of items in theText
  63.   if dItemCount > 1 then
  64.     set dNewText to item 1 of theText
  65.     repeat with i = 2 to dItemCount
  66.       set dNewText to dNewText & theSubString & item i of theText
  67.     end repeat
  68.     return dNewText
  69.   else
  70.     return theText
  71.   end if
  72.   set the itemDelimiter to oldItemDelim
  73. end
  74.  
  75. on mDisableScreenSaver me
  76.   if not isPC() then
  77.     exit
  78.   end if
  79.   set pScreenSaverDisabled to 1
  80.   set dResult to baDisableScreenSaver(pScreenSaverDisabled)
  81. end
  82.  
  83. on mRestoreScreenSaver me
  84.   if not isPC() then
  85.     exit
  86.   end if
  87.   set pScreenSaverDisabled to 0
  88.   set dResult to baDisableScreenSaver(pScreenSaverDisabled)
  89. end
  90.  
  91. on initAlertFields me, theLowestSetting
  92.   if not isPC() then
  93.     exit
  94.   end if
  95.   case theLowestSetting of
  96.     8:
  97.       set theString to "256"
  98.     16:
  99.       set theString to "Thousands of"
  100.     24, 32:
  101.       set theString to "Millions of"
  102.     otherwise:
  103.       set theString to "Lower than your current"
  104.   end case
  105.   repeat with i = 1 to count(pAlertList)
  106.     set prop to getPropAt(pAlertList, i)
  107.     setProp(pAlertList, prop, InsertColorString(me, getAt(pAlertList, i), theString))
  108.   end repeat
  109. end
  110.  
  111. on CheckMonitorDepth me
  112.   if not isPC() then
  113.     if getBitDepth(me) <> 8 then
  114.       set the colorDepth to 8
  115.     end if
  116.     exit
  117.   end if
  118.   if pLowestSetting = getBitDepth(me) then
  119.     case pCurMode of
  120.       0:
  121.         set pCurMode to 0
  122.       1:
  123.         set pCurMode to 3
  124.       4:
  125.         set pCurMode to 6
  126.       7:
  127.         set pCurMode to 8
  128.       9:
  129.         set pCurMode to 10
  130.     end case
  131.     setPrevReset(me, pCurMode)
  132.     exit
  133.   else
  134.     if getBitDepth(me) < 8 then
  135.       set pLowMode to 1
  136.     end if
  137.     case pCurMode of
  138.       0:
  139.         setPrevReset(me, 1)
  140.         set the colorDepth to pLowestSetting
  141.         CheckMonitorDepth(me)
  142.         exit
  143.       1:
  144.         set dRestartSetting to getRestartSetting(me, 8)
  145.         if dRestartSetting contains "dynamic" then
  146.           set dReStartVal to 4
  147.           if pLowMode then
  148.             callBox(me, #DynamicAlertTextLow, 1, ["Yes", "No"])
  149.           else
  150.             callBox(me, #DynamicAlertText, 1, ["Yes", "No"])
  151.           end if
  152.         else
  153.           if dRestartSetting contains "restart" then
  154.             set dReStartVal to 7
  155.             if pLowMode then
  156.               callBox(me, #RestartAlertTextLow, 1, ["Yes", "No"])
  157.             else
  158.               callBox(me, #RestartAlertText, 1, ["Yes", "No"])
  159.             end if
  160.           else
  161.           end if
  162.         end if
  163.         case gDiagResult of
  164.           1:
  165.             setPrevReset(me, dReStartVal)
  166.             changeColorDepthWin(me, dRestartSetting)
  167.           2:
  168.             setPrevReset(me, 0)
  169.             if pLowMode then
  170.               quit()
  171.             end if
  172.             exit
  173.         end case
  174.         CheckMonitorDepth(me)
  175.         exit
  176.       4:
  177.         callBox(me, #FailedDynamicChangeText, 1, ["Yes", "No"])
  178.         case gDiagResult of
  179.           1:
  180.             setPrevReset(me, 7)
  181.             dresRestart()
  182.             exit
  183.           2:
  184.             setPrevReset(me, 0)
  185.             if pLowMode then
  186.               quit()
  187.             end if
  188.             exit
  189.         end case
  190.       7:
  191.         if pLowMode then
  192.           callBox(me, #LowModeExit, 0, ["OK", "OK"])
  193.           quit()
  194.         end if
  195.         callBox(me, #FailedRestartChangeText, 1, ["Yes", "No"])
  196.         case gDiagResult of
  197.           1:
  198.             setPrevReset(me, 9)
  199.             quit()
  200.           2:
  201.             setPrevReset(me, 0)
  202.             exit
  203.         end case
  204.       9:
  205.         if pLowMode then
  206.           callBox(me, #LowModeExit, 0, ["OK", "OK"])
  207.           quit()
  208.         end if
  209.         callBox(me, #FailedManualChangeText, 1, ["Yes", "No"])
  210.         case gDiagResult of
  211.           1:
  212.             setPrevReset(me, 9)
  213.             quit()
  214.           2:
  215.             setPrevReset(me, 0)
  216.             exit
  217.         end case
  218.       otherwise:
  219.         setPrevReset(me, 0)
  220.         CheckMonitorDepth(me)
  221.         exit
  222.     end case
  223.   end if
  224. end
  225.  
  226. on mRestoreMonitor me
  227.   if the machineType <> 256 then
  228.     if getBitDepth(me) <> pOrigDepth then
  229.       set the colorDepth to pOrigDepth
  230.     end if
  231.   else
  232.     mRestoreScreenSaver(me)
  233.     case pCurMode of
  234.       3:
  235.         set the colorDepth to pOrigDepth
  236.         updateStage()
  237.         if getBitDepth(me) <> pOrigDepth then
  238.           setPrevReset(me, 11)
  239.           mRestoreMonitor(me)
  240.           exit
  241.         end if
  242.       6, 8:
  243.         setPrevReset(me, 0)
  244.         set dRestartSetting to getRestartSetting(me, pOrigDepth)
  245.         if dRestartSetting contains "dynamic" then
  246.           callBox(me, #dynamicRestore, 1, ["Yes", "No"])
  247.         else
  248.           if dRestartSetting contains "restart" then
  249.             callBox(me, #restartRestore, 1, ["Yes", "No"])
  250.           end if
  251.         end if
  252.         case gDiagResult of
  253.           1:
  254.             changeColorDepthWin(me, dRestartSetting)
  255.           2:
  256.             exit
  257.         end case
  258.         exit
  259.       10:
  260.         callBox(me, #ManualRestore, 0, ["Yes", "No"])
  261.       11:
  262.         setPrevReset(me, 0)
  263.         set dRestartSetting to getRestartSetting(me, pOrigDepth)
  264.         if dRestartSetting contains "dynamic" then
  265.           callBox(me, #dynamicRestore, 1, ["No", "Yes"])
  266.         else
  267.           if dRestartSetting contains "restart" then
  268.             callBox(me, #restartRestore, 1, ["No", "Yes"])
  269.           end if
  270.         end if
  271.         case gDiagResult of
  272.           1:
  273.             exit
  274.           2:
  275.             changeColorDepthWin(me, dRestartSetting)
  276.         end case
  277.         exit
  278.     end case
  279.     setPrevReset(me, 0)
  280.   end if
  281. end
  282.  
  283. on getPrevReset me
  284.   if not isPC() then
  285.     exit
  286.   end if
  287.   set prefFile to getOSDirectory() & "\spookydisplay.ini"
  288.   set dReStartVal to integer(baReadIni("RestartSettings", "RestartVal", "0", prefFile))
  289.   set dColorDepth to integer(baReadIni("RestartSettings", "Color", string(getBitDepth(me)), prefFile))
  290.   return [dReStartVal, dColorDepth]
  291. end
  292.  
  293. on setPrevReset me, theMode
  294.   if not isPC() then
  295.     exit
  296.   end if
  297.   set pCurMode to theMode
  298.   set prefFile to getOSDirectory() & "\spookydisplay.ini"
  299.   set dFileExists to FileExists(prefFile)
  300.   if pCurMode then
  301.     set dResult to baWriteIni("RestartSettings", "RestartVal", string(pCurMode), prefFile)
  302.     set dResult to baWriteIni("RestartSettings", "Color", string(pOrigDepth), prefFile)
  303.   else
  304.     if not dFileExists and not pCurMode then
  305.       set dResult to baDeleteFile(prefFile)
  306.     end if
  307.   end if
  308. end
  309.  
  310. on changeColorDepthWin me, theChangeString
  311.   if not isPC() then
  312.     exit
  313.   end if
  314.   set lineNum to findSetting(me, theChangeString)
  315.   if lineNum > 0 then
  316.     if word 7 of theChangeString = "dynamic" then
  317.       dresDynamicSetDisplay(lineNum)
  318.     else
  319.       if word 7 of theChangeString = "restart" then
  320.         dresRestartSetDisplay(lineNum)
  321.         dresRestart()
  322.       end if
  323.     end if
  324.   end if
  325.   quit()
  326. end
  327.  
  328. on getRestartSetting me, theBitDepth
  329.   if not isPC() then
  330.     exit
  331.   end if
  332.   set theBitDepth to string(theBitDepth)
  333.   set dCurSettings to dresGetCurrentDisplay()
  334.   set dSettingsList to dresGetDisplaySettings()
  335.   set dGoodSettingsList to []
  336.   repeat with i = 1 to the number of lines in dSettingsList
  337.     set dSetting to line i of dSettingsList
  338.     if (word 1 of dCurSettings = word 1 of dSetting) and (word 3 of dSetting = theBitDepth) then
  339.       add(dGoodSettingsList, dSetting)
  340.     end if
  341.   end repeat
  342.   if count(dGoodSettingsList) then
  343.     repeat with dGoodSetting in dGoodSettingsList
  344.       if dGoodSetting contains "dynamic" then
  345.         set dReturnSetting to dGoodSetting
  346.         exit repeat
  347.       end if
  348.     end repeat
  349.     if voidp(dReturnSetting) then
  350.       set dReturnString to getAt(dGoodSettingsList, 1)
  351.     end if
  352.   else
  353.     set dReturnString to EMPTY
  354.   end if
  355.   return dReturnString
  356. end
  357.  
  358. on findSetting me, theLine
  359.   if not isPC() then
  360.     exit
  361.   end if
  362.   set foundLine to 0
  363.   set allSettings to dresGetDisplaySettings()
  364.   set numLines to the number of lines in allSettings
  365.   repeat with X = 1 to numLines
  366.     if line X of allSettings = theLine then
  367.       set foundLine to X
  368.       exit repeat
  369.     end if
  370.   end repeat
  371.   return foundLine
  372. end
  373.  
  374. on getBitDepth me
  375.   if not isPC() then
  376.     return the colorDepth
  377.   else
  378.     set dCurSettings to dresGetCurrentDisplay()
  379.     set dBitDepth to word 3 of dCurSettings
  380.     return integer(dBitDepth)
  381.   end if
  382. end
  383.  
  384. on getLowestSetting me
  385.   if not isPC() then
  386.     exit
  387.   end if
  388.   set dCurSettings to dresGetCurrentDisplay()
  389.   set dSettingsList to dresGetDisplaySettings()
  390.   set dGoodSettings to []
  391.   repeat with i = 1 to the number of lines in dSettingsList
  392.     set dSetting to line i of dSettingsList
  393.     if word 1 of dCurSettings = word 1 of dSetting then
  394.       set dBitDepth to integer(word 3 of dSetting)
  395.       if integerp(dBitDepth) then
  396.         if dBitDepth >= 8 then
  397.           add(dGoodSettings, dBitDepth)
  398.         end if
  399.       end if
  400.     end if
  401.   end repeat
  402.   return min(dGoodSettings)
  403. end
  404.