コード例 #1
0
 private void DataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
 {
     if (InformData.IsCurrentCellDirty)
     {
         if (InformData.CurrentCell.ColumnIndex == 0)
         {
             InformData.CommitEdit(DataGridViewDataErrorContexts.Commit);
         }
     }
 }
コード例 #2
0
        // This runs continously, every second it checks for new addresses
        // If they're new it starts the informers. In pumps the informers
        // until they're finished (success or failure)
        IEnumerator CheckAddresses()
        {
            for (;;)
            {
                // I'm not sure what to do here. The original node.js version
                // had advantages here. One is it's naturally multi-threaded
                // so this takes zero time from the main thread.
                //
                // The other is the game wasn't running in node it was
                // running in either the browser or unity so again no
                // effect on the game.
                //
                // I could move this to another thread but the reason this
                // exists is that students would move their machine to another
                // network, stop and start unity but that wouldn't start and stop
                // node.js so without this polling node.js would have kept on
                // the old network.
                //
                // Now that this is in Unity it's more likely the user
                // will start and stop Unity so no reason to poll.
                //
                // For now I'm just keeping this code in here but
                // it only looks for new addresses once.
                bool haveNewAddresses = false;

                if (once_ || forever_)
                {
                    once_ = false;
                    string[] addresses       = HFTIpUtils.GetLocalIPAddresses();
                    string   newAddressesStr = String.Join(", ", addresses);
                    if (!newAddressesStr.Equals(oldAddressesStr_))
                    {
                        oldAddressesStr_ = newAddressesStr;
                        var data = new InformData(addresses, options_.port);
                        var json = Serializer.Serialize(data);
                        log_.Info("sending: " + json);
                        addressBytes_    = System.Text.Encoding.UTF8.GetBytes(json);
                        haveNewAddresses = true;
                    }
                }

                foreach (Informer informer in informers_)
                {
                    informer.Inform(haveNewAddresses, this, addressBytes_, oldAddressesStr_);
                }

                yield return(new WaitForSeconds(1.0f));
            }
        }
コード例 #3
0
        private Story(byte[] memory)
        {
            this.memory               = memory;
            this.version              = Header.ReadVersion(memory);
            this.serialNumber         = Header.ReadSerialNumber(memory);
            this.releaseNumber        = Header.ReadReleaseNumber(memory);
            this.checksum             = Header.ReadChecksum(memory);
            this.actualChecksum       = Header.CalculateChecksum(memory);
            this.routinesOffset       = Header.ReadRoutinesOffset(memory);
            this.stringsOffset        = Header.ReadStringsOffset(memory);
            this.instructionCache     = new InstructionCache((memory.Length - Header.ReadStaticMemoryBase(memory)) / 8);
            this.ztext                = new ZText(memory);
            this.memoryMap            = new MemoryMap(memory);
            this.informData           = new InformData(memory, this.memoryMap, ztext);
            this.objectTable          = new ZObjectTable(memory, ztext);
            this.globalVariablesTable = new GlobalVariablesTable(memory);
            this.dictionary           = new ZDictionary(this, ztext);
            this.mainRoutineAddress   = Header.ReadMainRoutineAddress(memory);

            RegisterInterpreter(new DefaultInterpreter());
        }
コード例 #4
0
ファイル: HFTSite.cs プロジェクト: greggman/hft-unity-gamepad
        // This runs continously, every second it checks for new addresses
        // If they're new it starts the informers. In pumps the informers
        // until they're finished (success or failure)
        IEnumerator CheckAddresses()
        {
            for (;;)
            {
                // I'm not sure what to do here. The original node.js version
                // had advantages here. One is it's naturally multi-threaded
                // so this takes zero time from the main thread.
                //
                // The other is the game wasn't running in node it was
                // running in either the browser or unity so again no
                // effect on the game.
                //
                // I could move this to another thread but the reason this
                // exists is that students would move their machine to another
                // network, stop and start unity but that wouldn't start and stop
                // node.js so without this polling node.js would have kept on
                // the old network.
                //
                // Now that this is in Unity it's more likely the user
                // will start and stop Unity so no reason to poll.
                //
                // For now I'm just keeping this code in here but
                // it only looks for new addresses once.
                bool haveNewAddresses = false;

                if (once_ || forever_)
                {
                    once_ = false;
                    string[] addresses = HFTIpUtils.GetLocalIPAddresses();
                    string newAddressesStr = String.Join(", ", addresses);
                    if (!newAddressesStr.Equals(oldAddressesStr_))
                    {
                        oldAddressesStr_ = newAddressesStr;
                        var data = new InformData(addresses, options_.port);
                        var json = Serializer.Serialize(data);
                        addressBytes_ = System.Text.Encoding.UTF8.GetBytes(json);
                        haveNewAddresses = true;
                    }
                }

                foreach(Informer informer in informers_)
                {
                    informer.Inform(haveNewAddresses, this, addressBytes_, oldAddressesStr_);
                }

                yield return new WaitForSeconds(1.0f);
            }
        }