void Skein::Import(const char* path) { Node* node = m_inst.root; bool added = false; CStdioFile recFile; if (recFile.Open(path,CFile::modeRead|CFile::typeText)) { CString recLine; while (recFile.ReadString(recLine)) { recLine.Trim(); if (recLine.GetLength() > 0) { CStringW recLineW = EscapeLine(CStringW(recLine),UsePrintable); Node* newNode = node->Find(recLineW); if (newNode == NULL) { newNode = new Node(recLineW,L"",L"",L"",false); node->Add(newNode); added = true; } node = newNode; } } if (added) { m_layout = false; NotifyChange(TreeChanged); NotifyEdit(true); } } }
bool Skein::Save(const char* path) { std::set<Node*> tempNodes; m_root->GetTempNodes(tempNodes,m_maxSaveTemp); Node* current = m_current->WillSaveNode(tempNodes) ? m_current : m_root; CString fileName = path; fileName += SKEIN_FILE; FILE* skeinFile = fopen(fileName,"wt"); if (skeinFile == NULL) return false; fprintf(skeinFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<Skein rootNode=\"%s\" xmlns=\"http://www.logicalshift.org.uk/IF/Skein\">\n" " <generator>Inform 7 for Windows</generator>\n" " <activeNode nodeId=\"%s\"/>\n", m_root->GetUniqueId(),current->GetUniqueId()); m_root->SaveNodes(skeinFile,tempNodes); fprintf(skeinFile,"</Skein>\n"); fclose(skeinFile); NotifyEdit(false); return true; }
void Skein::SetLine(Node* node, LPCWSTR line) { if (node->SetLine(line)) NotifyEdit(true); m_layout = false; NotifyChange(NodeTextChanged); }
void Skein::SetLabel(Node* node, LPCWSTR label) { if (node->SetLabel(label)) NotifyEdit(true); m_layout = false; NotifyChange(NodeTextChanged); }
void Skein::NewLine(const CStringW& line) { bool nodeAdded = false; CStringW nodeLine = EscapeLine(line,UsePrintable); // Is there a child node with the same line? Node* node = m_inst.current->Find(nodeLine); if (node == NULL) { node = new Node(nodeLine,L"",L"",L"",false); m_inst.current->Add(node); nodeAdded = true; } // Make this the new current node m_inst.current = node; m_played = node; // Notify any listeners if (nodeAdded) { m_layout = false; NotifyChange(TreeChanged); NotifyEdit(true); } else NotifyChange(ThreadChanged); NotifyShowNode(node,ShowNewLine); }
void CFFPlugsRow::RemoveModRange() { if (SliderHasSel()) { m_ParmSlider.ClearSel(TRUE); SetValFromSlider(); NotifyEdit(IDC_FF_PARM_SLIDER); } }
void Skein::Unlock(Node* node, bool notify) { if (node->SetLocked(false)) NotifyEdit(true); for (int i = 0; i < node->GetNumChildren(); i++) Unlock(node->GetChild(i),false); if (notify) NotifyChange(LockChanged); }
void CFFPlugsRow::SetModRange(float Start, float End) { m_ParmSlider.SetNormSelection(Start, End); m_ParmSlider.GetNormSelection(Start, End); // get quantized values if (Start == End) m_ParmSlider.ClearSel(TRUE); SetValFromSlider(); NotifyEdit(IDC_FF_PARM_SLIDER); }
void Skein::Lock(Node* node) { while (node != NULL) { if (node->SetLocked(true)) NotifyEdit(true); node = node->GetParent(); } NotifyChange(LockChanged); }
void Skein::Bless(Node* node, bool all) { while (node != NULL) { if (node->Bless()) NotifyEdit(true); node = all ? node->GetParent() : NULL; } NotifyChange(NodeColourChanged); }
Skein::Node* Skein::AddNew(Node* node) { Node* newNode = new Node(L"",L"",L"",L"",false); node->Add(newNode); m_layout = false; NotifyChange(TreeChanged); NotifyEdit(true); return newNode; }
void Skein::Reset() { delete m_inst.root; m_inst.root = new Node(L"- start -",L"",L"",L"",false); m_inst.current = m_inst.root; m_played = m_inst.root; m_layout = false; NotifyChange(TreeChanged); NotifyEdit(false); }
void CFFPlugsRow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { if (pScrollBar == (CScrollBar *)&m_ParmSlider) { switch (nSBCode) { case SB_SLIDER_SELECTION: NotifyEdit(IDC_FF_PARM_SLIDER); break; } } CRowDlg::OnHScroll(nSBCode, nPos, pScrollBar); }
bool Skein::Save(const char* path) { for (std::vector<Instance>::iterator it = m_other.begin(); it != m_other.end(); ++it) it->Save(path); if (m_inst.Save(path)) { NotifyEdit(false); return true; } return false; }
Skein::Node* Skein::AddNewParent(Node* node) { Node* newNode = new Node(L"",L"",L"",L"",false); node->GetParent()->Replace(node,newNode); newNode->Add(node); m_layout = false; NotifyChange(TreeChanged); NotifyEdit(true); return newNode; }
bool Skein::RemoveSingle(Node* node) { bool removed = false; Node* parent = node->GetParent(); if (parent != NULL) { bool inCurrent = InCurrentThread(node); removed = parent->RemoveSingle(node); if (inCurrent) { m_inst.current = m_inst.root; m_played = m_inst.root; } m_layout = false; NotifyChange(TreeChanged); } if (removed) NotifyEdit(true); return removed; }
void Skein::Load(const char* path) { if (m_inst.skeinFile.IsEmpty()) { Reset(); return; } CString fileName; fileName.Format("%s\\%s",path,m_inst.skeinFile); // Create an XML document instance CComPtr<IXMLDOMDocument> doc; if (FAILED(doc.CoCreateInstance(CLSID_DOMDocument))) { Reset(); return; } // Load the skein XML into the document VARIANT_BOOL success = 0; if (doc->load(CComVariant(fileName),&success) != S_OK) { CComPtr<IXMLDOMParseError> error; doc->get_parseError(&error); long line = 0; error->get_line(&line); CComBSTR text; error->get_srcText(&text); CComBSTR reason; error->get_reason(&reason); TRACE("Failed to load skein XML\n line: %d\n text: %S\n reason: %S\n", line,text.m_str,reason.m_str); Reset(); return; } // Get all the item nodes CComPtr<IXMLDOMNodeList> items; doc->selectNodes(L"/Skein/item",&items); // Create a node object for each XML item node std::map<CStringW,Node*> nodes; CComPtr<IXMLDOMNode> item; while (items->nextNode(&item) == S_OK) { CStringW id = StringFromXML(item,L"@nodeId"); CStringW command = StringFromXML(item,L"command"); CStringW label = StringFromXML(item,L"annotation"); CStringW result = StringFromXML(item,L"result"); CStringW commentary = StringFromXML(item,L"commentary"); bool played = BoolFromXML(item,L"played/text()",false); bool changed = BoolFromXML(item,L"changed/text()",false); bool temp = BoolFromXML(item,L"temporary/text()",true); int score = IntFromXML(item,L"temporary/@score"); nodes[id] = new Node(command,label,result,commentary,changed); item = NULL; } // Loop through the XML item nodes again, setting up the parent-child links items->reset(); while (items->nextNode(&item) == S_OK) { Node* parentNode = nodes[StringFromXML(item,L"@nodeId").m_str]; CComPtr<IXMLDOMNodeList> children; item->selectNodes(L"children/child",&children); CComPtr<IXMLDOMNode> child; while (children->nextNode(&child) == S_OK) { Node* childNode = nodes[StringFromXML(child,L"@nodeId").m_str]; parentNode->Add(childNode); child = NULL; } item = NULL; } // Get the root and current nodes CStringW root = StringFromXML(doc,L"/Skein/@rootNode"); CStringW current = StringFromXML(doc,L"/Skein/activeNode/@nodeId"); // Discard the current skein and replace with the new delete m_inst.root; m_inst.root = nodes[root]; m_inst.current = nodes[current]; if (m_inst.current == NULL) m_inst.current = m_inst.root; m_played = m_inst.root; m_layout = false; NotifyChange(TreeChanged); NotifyEdit(false); }
void CFFPlugsRow::OnChangedModFreq(NMHDR* pNMHDR, LRESULT* pResult) { UpdateOscFreq(); NotifyEdit(IDC_FF_MOD_FREQ); *pResult = 0; }
void CFFPlugsRow::OnChangedModPW(NMHDR* pNMHDR, LRESULT* pResult) { NotifyEdit(IDC_FF_MOD_PW); *pResult = 0; }
void CFFPlugsRow::OnSelchangeModWave() { NotifyEdit(IDC_FF_MOD_WAVE); }
void CFFPlugsRow::OnChangedParmEdit(NMHDR* pNMHDR, LRESULT* pResult) { NotifyEdit(IDC_FF_PARM_EDIT); *pResult = 0; }
void Skein::SetExpectedText(Node* node, LPCWSTR text) { if (node->SetExpectedText(text)) NotifyEdit(true); NotifyChange(NodeColourChanged); }
void CFFPlugsRow::OnModEnab() { NotifyEdit(IDC_FF_MOD_ENAB); }