void HyperPathLoader::Load(const StringPiece &s, HyperPath &path) { path.nodeSeqs.clear(); // Tokenize the string and store the tokens in m_tokenSeq. m_tokenSeq.clear(); for (TreeFragmentTokenizer p(s); p != TreeFragmentTokenizer(); ++p) { m_tokenSeq.push_back(*p); } // Determine the height of the tree fragment. int height = DetermineHeight(); // Ensure path contains the correct number of elements. path.nodeSeqs.resize(height+1); // Generate the fragment's NodeTuple sequence and store it in m_nodeTupleSeq. GenerateNodeTupleSeq(height); // Fill the HyperPath. for (int depth = 0; depth <= height; ++depth) { int prevParent = -1; // TODO Generate one node tuple sequence for each depth instead of one // TODO sequence that contains node tuples at every depth for (std::vector<NodeTuple>::const_iterator p = m_nodeTupleSeq.begin(); p != m_nodeTupleSeq.end(); ++p) { const NodeTuple &tuple = *p; if (tuple.depth != depth) { continue; } if (prevParent != -1 && tuple.parent != prevParent) { path.nodeSeqs[depth].push_back(HyperPath::kComma); } path.nodeSeqs[depth].push_back(tuple.symbol); prevParent = tuple.parent; } } }
void GWFactoryList::DoRender(ZMap &the_map, SDL_Surface *dest) { int shift_x, shift_y, view_w, view_h; int tx, ty; if(!show) return; if(!finished_init) return; if(!ols) return; if(our_team == NULL_TEAM) return; the_map.GetViewShiftFull(shift_x, shift_y, view_w, view_h); x = shift_x; y = shift_y + view_h; DetermineHeight(view_h); y -= height; //top the_map.RenderZSurface(&main_top_img, x, y); //entries DoRenderEntries(the_map, dest); //right { tx = x + (main_top_img.GetBaseSurface()->w - main_right_img.GetBaseSurface()->w); ty = y + main_top_img.GetBaseSurface()->h; while(ty < shift_y + view_h) { the_map.RenderZSurface(&main_right_img, tx, ty); ty += main_right_img.GetBaseSurface()->h; } } if(entry_list.size()) { int scroll_top; int scroll_bottom; int scroll_missing_entries; //buttons up_button.SetOffsets(123, main_top_img.GetBaseSurface()->h + 2); up_button.DoRender(the_map, dest, x, y); down_button.SetOffsets(123, height - 11); down_button.DoRender(the_map, dest, x, y); //scrollbar scroll_top = main_top_img.GetBaseSurface()->h + 14; scroll_bottom = height - 14; scroll_bar.SetOffsets(123, scroll_top); scroll_bar.SetHeight(scroll_bottom - scroll_top); scroll_missing_entries = entry_list.size() - show_able_entries; if(scroll_missing_entries > 0) scroll_bar.SetPercentDown(1.0 * show_start_entry / scroll_missing_entries); else scroll_bar.SetPercentDown(0); scroll_bar.SetPercentViewable(1.0 * show_able_entries / entry_list.size()); scroll_bar.DoRender(the_map, dest, x, y); } }